-1

I am getting some data from a website using it's API which is in JSON format. The code required is here -

{
    "response": {
        "success": 1,
        "current_time": 1391942785,
        "prices": {
           "5021": {
               "6": {
                "0": {
                    "current": {
                        "currency": "metal",
                        "value": 7,
                        "last_update": 1388772055,
                        "difference": 0.175
                    }
                }
            }
         }
      }
   }
}

Now I want to ask you guys, If I want to parse this and use the part about the value which is 7 at the moment. How can I do that? Just provide me with a sample that will print the value? or open up a messagebox?

spaghettifunk
  • 1,936
  • 4
  • 24
  • 46
Bone
  • 859
  • 2
  • 9
  • 17

1 Answers1

1

You can use JSON.NET library e.g. :

var obj = JsonConvert.DeserializeObject<JContainer>(jsonText);
var value = (int)obj["response"]["prices"]["5021"]["6"]["0"]["current"]["value"];
// value = 7
digEmAll
  • 56,430
  • 9
  • 115
  • 140