这里slahses用来逃避你的JSON编码字符串的charatcer "
(不是JSON对象,因为
> JSON.parse("{messages:1}")
SyntaxError: Unexpected token m
at Object.parse (native)
at repl:1:7
at REPLServer.eval (repl.js:80:21)
at Interface.<anonymous> (repl.js:182:12)
at Interface.emit (events.js:67:17)
at Interface._onLine (readline.js:162:10)
at Interface._line (readline.js:426:8)
at Interface._ttyWrite (readline.js:603:14)
at ReadStream.<anonymous> (readline.js:82:12)
at ReadStream.emit (events.js:88:20)
,因此密钥必须与"
封闭来表示一个字符串,但你不能只是把"
里面的字符串。为了解决这个问题JSON解析器追加\
> JSON.parse("{\"messages\":1}")
{ messages: 1 }
所以当你分析,只需拨打会话串JSON.Parse
> JSON.parse("{\"messages\":{\"cometchat\":{\"timedifference\":0,\"cometchat_buddytime\":0,\"msgavails\":\"\"}}}")
{ messages:
{ cometchat:
{ timedifference: 0,
cometchat_buddytime: 0,
msgavails: '' } } }