Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created October 25, 2012 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyuehh/3949992 to your computer and use it in GitHub Desktop.
Save lyuehh/3949992 to your computer and use it in GitHub Desktop.
json
JSON 字面量
>>> ({"a":"\a"})
Object { a="a"}
>>> ({"a":"\\a"})
Object { a="\a"}
>>> ({"a":"\\\a"})
Object { a="\a"}
>>> ({"a":"\\\\a"})
Object { a="\\a"}
JSON.parse()
>>> JSON.parse('{"a":"\a"}')
Object { a="a"}
>>> JSON.parse('{"a":"\\a"}') 报错
>>> JSON.parse('{"a":"\\\a"}') 报错
>>> JSON.parse('{"a":"\\\\a"}')
Object { a="\a"}
JSON.stringify()
>>> JSON.stringify({"a":"\a"})
"{"a":"a"}"
>>> JSON.stringify({"a":"\\a"})
"{"a":"\\a"}"
>>> JSON.stringify({"a":"\\\a"})
"{"a":"\\a"}"
>>> JSON.stringify({"a":"\\\\a"})
"{"a":"\\\\a"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment