日期:2014-05-16 浏览次数:20605 次
<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">{ "ArrayOfFunction":{ "Actives":"", "Description":"111", "FunctionName":"12345", "PageName":"#", "PagePath":"#", "functionid":"05BA37E0-0BA6-4236-9A30-5D4C51D21368" } }</string>
var xml = '<?xml version="1.0" encoding="utf-8"?>'+ '<string xmlns="http://tempuri.org/">{'+ ' "ArrayOfFunction":{'+ ' "Actives":"",'+ ' "Description":"111",'+ ' "FunctionName":"12345",'+ ' "PageName":"#",'+ ' "PagePath":"#",'+ ' "functionid":"05BA37E0-0BA6-4236-9A30-5D4C51D21368"'+ ' }'+ '}</string>'; var json = eval('('+/{[\s\S]+}/.exec(xml)[0]+')'); alert(json)
------解决方案--------------------
最好是解析xml获取需要的节点内容,要不正则提取复制结构的json有得你弄的了
2#就是用正则提取json字符串出来然后eval生成json对象