Reputation: 1651
I have a following JSON repsonse from a API.
"{\"status\":\"True\", \"itemID\":\"201\"}".
On client side, how do I get values from status and itemID. I am NOT working in javascript. This is a c# class.
Upvotes: 1
Views: 207
Reputation: 3558
Use library to work with json. For example, JSON.NET
Here is example:
string json = @"{
""Name"": ""Apple"",
""Expiry"": new Date(1230422400000),
""Price"": 3.99,
""Sizes"": [
""Small"",
""Medium"",
""Large""
]
}";
JObject o = JObject.Parse(json);
string name = (string)o["Name"];
// Apple
JArray sizes = (JArray)o["Sizes"];
string smallest = (string)sizes[0];
// Small
Upvotes: 1
Reputation: 2505
Take a look at this nifty C# 4.0 implementation http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/08/22/using-c-4.0-and-dynamic-to-parse-json.aspx
Upvotes: 0