Pankaj Dwivedi Pankaj Dwivedi - 2 years ago 140
JSON Question

How can iterate over JSON object and print its properties and their values?

I want to navigate each property in the JSON below in JavaScript. The below JSON contains two records for reference but in real time will have numerous such records.


I want to get the values of the fields "Status", "CreatorLoginId" and "Name" to assign them to something else.

How should I do it?

Max Max
Answer Source
            var myJSON = JSON.parse('{"Record_0":[{"Status":"CREATED","CreatorLoginId":"sandhya","Name":"G1"}],"Record_1":[{"Status":"CREATED","CreatorLoginId":"San","Name":"G2"}]}');
            for(var pr in myJSON)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download