var arrays=new Array();
//JSON.stringify() 不能转下标非1,2,3这种数字的数组,
//所以采用新建对象的方式添加数据
var products={};
products['productid']='32';
products['name']='手机';
arrays.push(products);
var products2={};
products2['productid']='33';
products2['name']='电脑';
arrays.push(products2);
var json_arrays = JSON.stringify(arrays);
console.log(json_arrays);
Js 数组转JSON格式
最新推荐文章于 2024-03-03 13:07:19 发布