Skip to content

Json path starting with 0

I’m trying to get the data from a https.get request to an API and the json path has a 0 at the beginning. What does it mean and how do I access the data?

 https.get(url, function(response) {
    response.on("data", function(data) {
      readableData = JSON.parse(data);
      length = readableData.0.length; // <-- inserting path (0.length) here doesnt work as usually

The path is 0.length and the json chart viewer throws an error.

The data looks like this in json viewer:

[
  {
    "length": "32260db8-40d3-4973-9031-ceef149189aa",
  }
]

Answer

0 is index of array, to get length of the array do

readableData.length; // 1

to select first array do

readableData[0].length; // 32260db8-40d3-4973-9031-ceef149189aa