I am looking for a loop through a JSON array and display the key and value.
This should be a simplified version of the following post, but I don't believe in the syntax: jQuery 'each' loop with a JSON array
I also saw the message Get key name in key / value pairs in JSON using jQuery? but it also seemed to contain a lot of code for a simple action.
This illustrates what I'm looking for (but this does not work):
var result = '{"FirstName":"John","LastName":"Doe","Email":"johndoe@johndoe.com","Phone":"123 dead drive"}'; $.each(result, function(k, v) { //display the key and value pair alert(k + ' is ' + v); });
There is no required jQuery requirement, but it is available. I can also restructure JSON if it shortens the required code.
json javascript jquery
JStark Oct 22 '11 at 16:46 2011-10-22 16:46
source share