主页 M

把json字符串转换成对象

2014-11-23 网页编程网 网页编程网

问题:有这样的字符串[{"CityId":18,"CityName":"西安","ProvinceId":27,"CityOrder":1},{"CityId":53,"CityName":"广州","ProvinceId":27,"CityOrder":1}],用js转换成json对象。

解答:
var data;

var json='[{"CityId":18,"CityName":"西安","ProvinceId":27,"CityOrder":1},{"CityId":53,"CityName":"广州","ProvinceId":27,"CityOrder":1}]';

eval("data="+json);

alert(data);

阅读原文
阅读 3858
123 显示电脑版