Labels:
jQuery,
jQuery Codes,
jQuery Tips,
JSON,
Parse JSON,
Tips
In this short post, you will find how you to parse the JSON string using jQuery. JSON (JavaScript Object Notation) is an data exchange format and which is human-readable data. jQuery provides a metohd called "parseJSON" which takes a well-formed JSON string and returns the resulting JavaScript object.
Related Post:
Feel free to contact me for any help related to jQuery, I will gladly help you.
Related Post:
Some facts about JSON
- JSON is limited to text and numeric values.
- It doesn't support binary data.
- An JSON object is a set of key / name pairs which starts with "{" and ends with "}".
$(document).ready(function() {
var jsonp = '[{"Lang":"jQuery","ID":"1"},{"Lang":"C#","ID":"2"}]';
var lang = '';
var obj = $.parseJSON(jsonp);
$.each(obj, function() {
lang += this['Lang'] + "<br/>";
});
$('span').html(lang);
});
See result below.Feel free to contact me for any help related to jQuery, I will gladly help you.