开发者

JSON to string array in C#

开发者 https://www.devze.com 2023-02-15 05:18 出处:网络
I have JSON string just like that [ { 开发者_Python百科\"markers\": { \"0\": \"13.775801,100.611199\",

I have JSON string just like that

[
    {
    开发者_Python百科    "markers": {
            "0": "13.775801,100.611199",
            "1": "13.775801,100.611199" 
        } 
    }
]

I would like to do markers list with string array.My JSON format is exactly same with that format.It might not be change anymore.How can I do for that ?


JavaScriptSerializer is a good option. It is in .NET Framework v3.5, so you won't need any 3rd Party library.

Here is an small example of how you can use it, although if you enter JavaScriptSerializer on Google, you will have lots of examples of how to parse it.

Basically, you need to define a type that fits the JSON format you need to parse, and use the Deserialize method of JavaScriptSerializer class.

Edit:

See @Marc Gravell's answer for a similar question: Parsing JSON using Json.net


You can try using DataContractJsonSerializer or you can try a bit easy to learn library on codeplex JSON.Net.

Hope this helps,

Regards

0

精彩评论

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