Convert JSON string to array of JSON objects in Javascript

arrays, javascript, json

Solution

Using jQuery:

var str = '{"id":1,"name":"Test1"},{"id":2,"name":"Test2"}';
var jsonObj = $.parseJSON('[' + str + ']');

`jsonObj` is your JSON object.

Problem

I would like to convert this string ``` {"id":1,"name":"Test1"},{"id":2,"name":"Test2"} ``` to array of 2 JSON objects. How should I do it? best

Original source