看我想这样做:
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
最后:
var myOriginalArray = $.parseJSON( json_myArray );
myOriginalArray 和 myArray 将是相同的,包括键 (myOriginalArray["a"])