Jason Khalili Jason Khalili - 1 year ago 68
Javascript Question

JSON select from array

I have the following JSON object:


I'm trying to access the data with
, but for some reason my output is just
. What am I doing wrong? Also, any subsequent index just seems to return the corresponding char value. For example:

Answer Source

In JavaScript, there is no such thing as a JSON object.

You have a JSON text, which is a string.

somestring[0] gives you the first character of that string.

Use JSON.parse() to convert your JSON text into a JavaScript array.