70331833
var json1 = [{"Guoshui": [300000, 500000, 600000, 800000, 1000000, 1200000, 1400000, 1600000, 1800000, 1600000, 1400000, 12 00000]},{"Dishui": [1100000, 1200100, 1300000, 1100000, 1050000, 1400000, 1200000, 1600000, 1800000, 1200000, 1400000, 110 0000]},{"Heji": [400000, 1300000, 1200000, 1100000, 1500000, 1400000, 1200000, 1600000, 1700000, 1100000, 1400000, 1400000 ]}]
There are the following objects: now want to integrate him into the array, forming the following array: [{name: ' IRS ', type: ' Bar ',data: [300000, 500000, 600000, 800000, 1000000, 1200000,1400000,1600000,1800000,1600000,1400000,1200000],Markpoint: {data: [{type: ' Max ', Name: ' Max '}, {type: ' min ', NA Me: ' Minimum value '}]}, Markline: {data: [{type: ' Average ', name: ' Average '}]}},{name: ' Local tax ', type: ' Bar ',data: [1100000, 1200100, 1300000, 1100000, 1050000, 1400000,1200000,1600000,1800000,1200000,1400000,1100000], Markpoint: {data: [{type: ' Max ', Name: ' Max '}, {type: ' min ', NA Me: ' Minimum value '}]}, Markline: {data: [{type: ' Average ', name: ' Average '}]}},{name: ' Total ', type: ' Bar ',data: [400000, 1300000, 1200000, 1100000, 1500000, 1400000,1200000,1600000,1700000,1100000,1400000,1400000], Markpoint: {data: [{type: ' Max ', Name: ' Max '}, {type: ' min ', NA Me: ' Minimum value '}]}, Markline: {data: [{type: ' Average ', name: ' Average '}]}}, in JavaScript, an array is actually an object, or an object that has an array of class attributes. It transforms the subscript of an array into a string, which is used as a property. If you use TypeOf to determine an array, the result is an object. The first value of the array automatically obtains the property name ' 0 ', the second value automatically obtains the property name ' 1 ', and so on. For JavaScript arrays and objects, let me first talk about their differences: objects are automatically expanded, and the properties of an object can be dynamically added by using ". Property name". Because the array is an object, it is also automatically expandable, and the properties of the object can be dynamically added by the ". Property name" or [property name] or push ().The object is traversed in the form of a for: In.. Random access, with the property name as the traversal of the key array traversal method is used for loop sequential access, you can directly use i++ as the traversal key. Not recommended for: In.. Random AccessBack to the previous question. JavaScript integrates the data in the object into another array to relate to the expansion of the array and the traversal of objects and arrays. So the notation is as follows: Var array1=[{name: ' IRS ', type: ' Bar ', Markpoint: {data: [{ty PE: ' Max ', Name: ' Max '}, {type: ' min ', Name: ' Minimum value '}]},markline: { Data: [{type: ' Average ', Name: ' Average '}]}},{name: ' Local tax ', Ty PE: ' Bar ', Markpoint: {data: [{type: ' Max ', Name: ' Max '}, {type: ' min ', Name: ' Minimum value '}]},markline: {data: [{type: ' Averag E ', name: ' Average '}]}},{name: ' Total ', type: ' Bar ', Markpoint: {data: [ {type: ' Max ', Name: ' Max '}, {type: ' min ', Name: ' Minimum value '}]},m Arkline: {data: [{type: ' Average ', Name: ' Average '} ]}}];//array1[0].data=json1[' Guoshui '];//array1[1].data=json1[' Dishui '];//array1[2].data=json1[' Hej I '];var i=0;for (item in Json1) {Array1[i++].data=json1[item];} Console.log (Json1[item]); Array[item]=json1[item];console.log (array1);
How JavaScript integrates data from objects into another array