JSON.parse () and JSON.stringify () the difference?

1.parse for parsing json object from a string. E.g

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

By JSON.parse (str) obtained:

Object: age:"23"

            name:"cpf"

            _proto_:Object

ps: single quote written in {} In addition, each property must be double quotes, otherwise it will throw an exception

2.stringify for the character string parsed from a subject, e.g.

There are a = {a 1, b 2}

By JSON.stringify (a) to give:

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

Guess you like

Origin www.cnblogs.com/FengYu19981001/p/11505792.html