Json.parse of and json.stringify of

  • 2020-03-30 03:24:03
  • OfStack

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


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

Results:


JSON.parse(str)

Object

age: "23"
name: "huangxiaojian"
__proto__: Object

Note: single quotes are written outside {}, and each attribute name must be in double quotes, otherwise an exception is thrown.

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


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

Results:


JSON.stringify(a)

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

PS: about json operation, here again for you to recommend a few more practical json online tools for your reference:

Online JSON code verification, verification, beautification, formatting tools:
(link: http://tools.jb51.net/code/json)

JSON online formatting tool:
(link: http://tools.jb51.net/code/jsonformat)

Online XML/JSON interconversion tool:
(link: http://tools.jb51.net/code/xmljson)

Json code online formatting/beautification/compression/editing/conversion tools:
(link: http://tools.jb51.net/code/jsoncodeformat)

Online json compression/escape tool:

(link: http://tools.jb51.net/code/json_yasuo_trans)

C language style /HTML/CSS/json code format beautification tool:
(link: http://tools.jb51.net/code/ccode_html_css_json)


Related articles: