I am actually trying to display canvas.js
chart using this json dynamically.
I have this result:
[{"s":40,"ProductName":"yoga pants"},
{"s":20,"ProductName":"trousers"},{"s":16,"ProductName":"shirts"},
{"s":10,"ProductName":"pants"},{"s":7,"ProductName":"RED"},
{"s":5,"ProductName":"Tank Top"}]
…which is a json string
I am getting this:
[{40: "yoga pants", x: 0},
{20: "trousers", x: 1},
{16: "shirts", x: 2},
{10: "pants", x: 3},
{7: "RED", x: 4},
{5: "Tank Top", x: 5}]
But i do not want this extra x:
value. I am using this code:
var result1 = JSON.parse(result);
var reformattedArray = result1.map(function (o)
{
var obj = {};
obj[o.s] = o.ProductName;
return obj;
});
Thanks in advance