1👍
✅
You can use the built in Object
helpers keys()
and values()
:
var Jsondata = {
"label1": 0,
"label2": 0,
"label3": 2,
"label4": 0,
"label5": 0
}
var labels = Object.keys(Jsondata)
var data = Object.values(Jsondata)
labels:
["label1", "label2", "label3", "label4", "label5"]
data:
[0, 0, 2, 0, 0]
Source:stackexchange.com