JSON.parse()与JSON.stringify()

parse()

For parsing a string object from json

Note: Each attribute name must be enclosed in double quotes, otherwise it will throw an exception, written in single quotes {} outside.

 

var str = '{"name":"zahngsan" , "age":"23"}'

JSON.parse(str)

 

 

stringify()

For a target character string parsed from

var a = {a:1,b:2}

JSON.stringify(a)

 

Guess you like

Origin www.cnblogs.com/ll15888/p/11246311.html