Shivank Verma Shivank Verma - 1 year ago 80
JSON Question

How to convert JavaScript object containing json string

I am having problem parsing JSON string into JS object .Please tell how to convert JavaScript object :

Object {d: "[{"worker_id":1,"worker_name":"Shivank"}]"}


Object { d: [{ "worker_id": 1, "worker_name": "Shivank" }] }

I have tried using



var dataFinal = JSON.stringify(data);
var d1 = eval('(' +dataFinal+ ')');

Answer Source

You have an object where one property value contains JSON so you only need to convert that value


data.d= JSON.parse(data.d);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download