-
-
Save NKid/103fc89f00fc967c78e9 to your computer and use it in GitHub Desktop.
JSON.stringify & JSON.parse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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