开发者

How to convert json from one format to another

开发者 https://www.devze.com 2023-01-14 11:44 出处:网络
I have a control that expects JSON in 开发者_运维问答a particular format.I have a service that spits out JSON in a different format.What\'s the best way to convert the JSON to the expected format? C#,

I have a control that expects JSON in 开发者_运维问答a particular format. I have a service that spits out JSON in a different format. What's the best way to convert the JSON to the expected format? C#, jQuery? I think I'd prefer to do it server-side.


With C# you can use System.Web.Script.Serialization.JavaScriptSerializer to parse your JSON string to an object or IDictionary.

MSDN: JavaScriptSerializer Class (System.Web.Script.Serialization)

With that object you could do anything you like, change values or maybe just parse it back to something like XML.

0

精彩评论

暂无评论...
验证码 换一张
取 消