Skip to content

Instantly share code, notes, and snippets.

@NKid
Created December 21, 2012 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NKid/103fc89f00fc967c78e9 to your computer and use it in GitHub Desktop.
Save NKid/103fc89f00fc967c78e9 to your computer and use it in GitHub Desktop.
JSON.stringify & JSON.parse
var strJson = '{"aaa":"111","bbb":"222"}';
console.log(typeof strJson); //string
var objJson = JSON.parse(strJson);
console.log(typeof objJson); //object
console.log(objJson.aaa); //111
var jsonDemo = {aaa:'111',bbb:'222'};
console.log(typeof jsonDemo); //object
var strDemo = JSON.stringify(jsonDemo);
console.log(typeof strDemo); //string
console.log(strDemo); //{"aaa":"111","bbb":"222"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment