The JSON data obtained from the background today is as follows:
var datajson = { ' 0 ': {id:1 } , ' 1 ': {id:2}, ' 2 ': {id:3 }, /c7> ' count ': 1}
This JSON we take the data very troublesome, datajson[' 0 '] to get to the first data, and now this JSON does not have the length of this property, so, can not be like the array over there to traverse the output processing.
Generally from the background to get the data should be the following, only to facilitate the JS access and processing data
var json = { data: [{ 1 },{ 2 },{ 3 } ] , 1 }
Below we use for...in to traverse the JSON object
var arr = []; for (var in datajson) { if (attr! = ' Count ') { Arr.push ( DATAJSON[ATTR]) }}
Well, it's convenient to turn JSON into the array we want, and then put the array back into JSON if necessary.
var json = { Data:arr, count:datajson[' count ']}console.log (JSON)
Well, look at the data that's handled well, a word--comfortable.
Special JSON object to the array, the most synthetic new JSON data