I'm looking to loop through a JSON array and display the key and value. Should be a simplified version of the following post but I don't seem to have the syntax correct: Jquery each loop with json array I also saw this post Get name of Key in Key/Value Pair in JSON using jQuery? but it also seemed like lots of code for a simple activity.
This illustrates what I'm looking for (but doesn't work):
var result = '{"FirstName":"John","LastName":"Doe","Email":"[email protected]","Phone":"123 dead drive"}';
$.each(result, function(k, v) {
//display the key and value pair
alert(k + ' is ' + v);
});
No manditory jQuery requirement, but it is available. I can also restructure the JSON if it cuts down the code required.