Parse JSON file with jQuery

March 15, 2014 | Last tested: May 2015 | 810 views | Comments

Use the function getJSON() to read and parse a JSON file with jQuery.

For example.

Use each() function to loop through the records of a parsed JSON file.

The generated JSON file named members.json from the tutorial Create a JSON file in PHP will be used on this example.

$.getJSON('members.json',function(data){
	$.each(data.members,function(index, value){
		$.each(value,function(index2, value2){
			console.log(value2);
		});
		console.log("\n");
	});
});

Result:

Please mouse over here to view the image.

 

Related Tutorials


Must Read