Pankaj Dwivedi Pankaj Dwivedi - 1 year ago 108
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)