Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading