JavaScript
Article
By Sam Deering

jquery convert json string to array

By Sam Deering

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:

--ADVERTISEMENT--

$('#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.

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account