Raj Yadav Raj Yadav - 1 year ago 102
Javascript Question

Json in javascript

i am getting a problem to get json string creating in javascript,
in console log getting pure json string



but when i am storing the output of the json in variable

it change like


so it can't parse by


Answer Source

You can use JSON.stringify to get a "parseable" string..


var str = JSON.stringify([{"elementId":"selectProduct","elemnetValue":"Y"},{"elementId":"productId","elemnetValue":"415"}]);

var json = JSON.parse(str);

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download