1

看我想这样做:

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"])

4

1 回答 1

0
JSON.stringify()

JSON.parse()
于 2012-05-19T19:21:06.320 回答