Manish
Manish

Reputation: 3521

How to parse JSON with only one key

I have one file as follows.

data.json:

[{
    "id": "plot"
  },
  [
    [195, 200, 0.3],
    [196, 196, 1],
    [196, 197, 0.9],
    [196, 198, 0.1]
  ]
]

I am trying to parse the title of using following code.

code:

$.getJSON('data.json', function(data) {
  var obj = JSON.parse(data);
  alert(obj.id);
});

But i get no output while using above code?

Upvotes: 0

Views: 404

Answers (1)

Try with:

obj[0].id; // Array of object.

Upvotes: 2

Related Questions