1

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.

2

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.