1

How can I parse this object using node.js? I am trying to extract 3.25. Thanks

"data": [["2020-05-04", 3.25],....]

2 Answers 2

1

Never mind. I got it.

data[0][1]

Sign up to request clarification or add additional context in comments.

Comments

1

I think this is much more suitable way to fetch data from your payload.

let val = {
    "data": [ [ "2020-05-04", 3.25 ], [ "2020-05-14", 1.25 ], [ "2020-02-04", 2.25 ]]
};

//-------------------------------

val["data"].forEach((element)=>{
    console.log(element[1]);
});

//-----------Or------------------

val["data"][0][1];

1 Comment

Thanks. That is a great way to get any data field. In my case, I simply needed the number in the first entry in huge JSON structure that was returned via a REST GET.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.