Response to Hook OData $ metadata and converting it from XML to JSON

The response Receive OData $ metadata in JSON format indicates that OData cannot return metadata as JSON by default.

But is it possible then to capture or track its response for the URL $metadata , and then convert it on the fly to JSON before sending it to the client?

I present the pseudo code as follows:

 [HttpGet] [ODataRoute("$metadata")] public string GetMetadataAsJson() { string xml = GetOdataMetadataAsXML(); string json = ConvertToJson(xml); return json; } 

I don’t know how to implement it correctly, although, in particular, I’m not sure how to get the standard OData response as a string and how to include the $metadata URL.

+8
json c # odata asp.net-web-api
source share

No one has answered this question yet.

See similar questions:

12
Retrieving OData $ metadata in JSON format

or similar:

3915
Why does Google add while (1); in your JSON answers?
2480
How do I send JSON data using Curl from a terminal / command line in Test Spring REST?
1349
Why can't Python parse this JSON data?
1186
Convert JS object to JSON string
1153
How to force ASP.NET Web API to return JSON instead of XML using Chrome?
632
JSON API standard response format?
6
WebAPI OData $ format for xml
0
Convert XML to JSON-Decorated Inside the Web API Method
0
Destroy OData for an object?
0
breeze cannot receive metadata in xml format

All Articles