🤯 $3/m for 3 month Sale Get 700+ Assessments, Books and Courses!

jquery convert json string to array

Sam Deering
Share

Simple jQuery snippet to convert JSON string to an array of objects and then interate output of thier values.

jquery convert json string to array

var data = JQUERY4U.DASHBOARD.data['widgets'];
data = $.parseJSON(data);
$.each(data, function (i,v)
{
  console.log(i,v);
});

Then to convert back simply use stringify:

$('#columns').html(data.stringify);

jquery convert json string to array2

To simply convert json to array, as of jquery 1.4.1 you can do this natively.