简体   繁体   中英

JSON to string array in C#

I have JSON string just like that

[
    {
        "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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM