JSON.parse()和JSON.stringify()

parse is used to parse a json object from a string, such as

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

result:

JSON.parse(str)

 

Object
  1. age"23"
  2. name"huangxiaojian"
  3. __proto__Object

 

 

Note: Single quotes are written outside {}, and each attribute name must be double quoted, otherwise an exception will be thrown.

 

stringify() is used to parse a string from an object, such as

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

result:

JSON.stringify(a)

"{"a":1,"b":2}"

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327077948&siteId=291194637