user1156596 user1156596 - 1 year ago 93
Javascript Question

How to pull properties and their values out of a JSON object

I have the following json object being returned and stored in a variable called data:


Since this is a single object and not an array of objects, I cannot do data[0], data[1] etc..

How can I pull out the min property and its value and store in a variable?

I've tried
var test = JSON.parse(data)
and then
but have failed.

Is there an easier way to do this?

Answer Source

var obj = {
   "data": {
      "min": 1,
      "q1": 59,
      "median": 117,
      "q3": 175,
      "max": 233

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download