How to Read and Parse JSON using jQuery
You should also take a look at my post about How to create, read and delete simple cookies and JSON cookies.
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 "}".
Below is sample jQuery code which parses JSON string using parseJSON method which returns an object.
$(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.