Tuesday, December 5, 2017

How to convert a josn array to object array in JavaScript.


To accomplish the same we could get use of the $.map function



Below code snippet will convert  the json in jsondata variable to JavaScript array



You can see the result in the console screen of browser.

var o = [{"Rating":"Negative","Value":1.0},{"Rating":"Neutral","Value":1.0},{"Rating":"Postive","Value":3.0}];

var arr = $.map(o, function(el) { return [[el.Rating,el.Value]]; })

console.log(arr)

https://jsfiddle.net/92e03nqu/

No comments:

Post a Comment