Parsing JSON

by Kyle Mitofsky

HTML

<h2>Parsing Json Strings</h2>
Open up the console to check the output












<!-- Post Info -->
<div style='position:fixed;bottom:0;left:0;    
            background:lightgray;width:100%;'>
    About this SO Post: <a href='http://stackoverflow.com/q/21431817/1366033'>JSON Format Issue in JQuery</a><br/>
    jQuery Documentation: <a href='http://api.jquery.com/jquery.parsejson/'>parseJSON</a><br/>
    JavaScript Documentation: <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse'>JSON.parse</a><br/>
<div>

JavaScript

var jsonData = "[{\"Name\":\"Name1\",\"Age\":20},{\"Name\":\"Name2\",\"Age\":23},{\"Name\":\"Name3\",\"Age\":28}]";

var obj1 = jQuery.parseJSON(jsonData);
console.log(obj1);

var obj2 = JSON.parse(jsonData);
console.log(obj2);