如何將Json數據轉換爲Array。我不能做到這一點 ,我有JSON數據爲:如何將Json轉換爲Array在javascript中爲chart.js
var setdata = [{
\t "data": [{
\t "month" : "January",
\t "name" : "Alex",
\t "count" : 10
\t }]
\t },
\t {
\t "data": [{
\t "month" : "February",
\t "name" : "Alex",
\t "count" : 20
\t },
\t { \t
\t "data": [{
\t "month" : "February",
\t "name" : "John",
\t "count" : 30
\t },
\t { \t
\t "data": [{
\t "month" : "February",
\t "name" : "Mark",
\t "count" : 40
\t }]
},
\t {
\t "data": [{
\t "month" : "March",
\t "name" : "Alex",
\t "count" : 10
\t },
\t { \t
\t "month" : "March",
\t "name" : "John",
\t "count" : 20
\t }]
\t }
]
我要轉換爲數組:
var months = ["January", "February", "March"]
var data = [10, 0, 0],
[0, 20, 10],
[0, 30, 20],
[0, 40, 0]
我想使用setData創建堆積圖。 js,你能爲我做這個嗎?請幫幫我。 謝謝。
爲什麼不能ü嘗試對象ARRY? –
如何做到這一點? – jane
請檢查這種格式。 https://jsfiddle.net/caravinden/zpzpbf85/。這將是更好的迭代和訪問 –