当前位置:首页 > 开发 > Web前端 > JavaScript > 正文

javascript的eval方法来处理action层传回的json字符串成javascript对象

发表于: 2012-12-06   作者:一炮送你回车库   来源:转载   浏览:
摘要: 对于这么一个正常的字符串data:{"id":1111,"parentDetailId":null,"detailCode":"1111","detailName":"小樱","detailLevel":null,"detailCarrCode&qu

对于这么一个正常的字符串data:
{"id":1111,"parentDetailId":null,"detailCode":"1111","detailName":"小樱","detailLevel":null,"detailCarrCode":null,"detailCarrName":null,"keepDateCode":null,

"keepDateName":null,"deliverDeptCode":null,"deliverDeptName":null,"saveSite":null,

"deliverRound":null,"verifyRound":null,"shelfRound":null,"shelfType":null,"batchFlag":null,

"detailTBNM":null,"createDTTM":null,"createId":null,"templateUrl":null,"fieldList":null}


转成javascript对象,
方法:
var aaa = null;
eval("aaa = "+data+";");


方法:
var aaa = eval("("+data+")");


或者用jquery-json插件,官网:http://code.google.com/p/jquery-json/

 

 

 

 

 

 

javascript的eval方法来处理action层传回的json字符串成javascript对象

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号