Often my server DB functions return the data in JSON format with all fields and values thrown in.
|
|
When we use charts (or even tables), this needs to be converted to an array of arrays. Most of the iterative functions work well with arrays and not objects.
We would want to convert the object into [['a', 1], ['b', 2]...]
.
Use Object.keys
We can convert JSON to array by using a map
function on Object.keys
.
|
|
Use the evil for
-in
Although slower, for-in results in a readable (?) loop.
|
|