kst
kst

Reputation: 1518

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 ?

Upvotes: 4

Views: 9645

Answers (2)

Oscar Mederos
Oscar Mederos

Reputation: 29863

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

Upvotes: 2

Chintan Shah
Chintan Shah

Reputation: 3703

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

Hope this helps,

Regards

Upvotes: 1

Related Questions