用eval转化对象

var str = '{"name": "tom","age": 12,"sex": "man"}';
var obj = eval("("+str+")");
console.log(obj);   // {name: "tom", age: 12, sex: "man"}
console.log(typeof obj);  // object

 

posted @ 2018-07-17 17:39  asimpleday  阅读(203)  评论(0编辑  收藏  举报