Look I want to do this:
function MyObject()
{
this.attr1;
this.attr2;
this.attr3;
}
var myArray = new Array();
myArray["a"] = new MyObject();
myArray["b"] = new MyObject();
myArray["c"] = new MyObject();
var json_myArray = CONVERT_TO_JSON( myArray ); // Or stringify
Finally:
var myOriginalArray = $.parseJSON( json_myArray );
The myOriginalArray and myArray will be identical, including the keys (myOriginalArray["a"])
JSON.stringify()
和
JSON.parse()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.