-2

How do I loop below JSON array in node JS??

[
    {
        "po_number": "PO1001",
        "product_id": "PD1001",
        "message": "Exists",
        "timestamp": "2016-05-01 10:33:02,123"
    },
    {
        "po_number": "PO1002",
        "product_id": "PD1002",
        "message": "Does not exist",
        "timestamp": "2016-05-01 10:33:03,432"
    }
]

Thanks a lot.

4
  • where do you want to pass? Commented Nov 8, 2017 at 11:38
  • @HemantRajpoot I think he means parse. Commented Nov 8, 2017 at 11:40
  • did you try JSON.parse? Commented Nov 8, 2017 at 11:43
  • @user1125829 Take a look at this Commented Nov 8, 2017 at 11:43

2 Answers 2

0

var jsonParsed = JSON.parse(json);

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

Comments

-2

Below is the answer.

var resjson = respBody;
resjson.forEach(function(table) {
 var ponum = table.po_number;
});

4 Comments

either your question is wrong . I see your answer , it means how can i iterate over json object . If that is the question change it . Parse means what @minil said.
I had respbody json array in the question. With my answer I am able to parse the respbody json array and able to fetch fields like po_number using node js..
your answers shows that json is already parsed and you are just looping it to fetch index data.
yes. question is changed to loop instead of parse. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.