Convert JSON String to Object

Total Post:4

Points:28
JQuery 
 489  View(s)
Ratings:
Rate this:

I want to convert Json string into array object.I have a JSON String like this.

{"label1":"Mindstick","label2":"123",}

and I want result like this

[{"label1":"Mindstick","label2":"123",}]



  1. Post:3

    Points:23
    Re: Convert JSON String to Object

    This can be done like this ...Try to push that object into an array,

    var xObj = {"label1":"Mindstick","label2":"123",}
    
    var xArr = [];
    xArr.push(xObj);
    console.log(JSON.stringify(xArr)); // 
    [{"label1":"Mindstick","label2":"123",}]




Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!