JSON.stringify(obj)将JS对象转为字符串

var json = { aa: ['sdddssd'],
  bb: [ '892394829342394792399', '23894723984729374932874' ],
  cc: ['11111111111111'] }

=> var string = JSON.stringify(json)

string:

{"aa":["sdddssd"],"bb":["892394829342394792399","23894723984729374932874"],"cc":["11111111111111"]}


JSON.parse(string)将字符串转为JS对象

JSON.parse(string):

=>

{ aa: ['sdddssd'],
  bb: [ '892394829342394792399', '23894723984729374932874' ],
  cc: ['11111111111111'] }

 

 

 

 

You can simply use JSON.parse.

node.js is built on V8, which provides the global object JSON[docs]. The definition of the JSON object is part of the ECMAScript 5 specification.

 

posted on 2014-12-06 23:39  wanghetao  阅读(80462)  评论(0编辑  收藏  举报