How Can I Convert Json Text To Json Object?
Possible Duplicate: How to parse JSON in JavaScript { 'data': [ { 'name': 'JoongBum Lee', 'id': '526210623' }, {
Solution 1:
Use JSON.parse
. It was introduced in ECMAScript 5 and is therefore not supported by <=IE7. You can find a JSON library to fill in support for older browsers, or if you use jQuery you can use $.parseJSON
.
var str = '"data": [ { "name": "JoongBum Lee", "id": "526210623" }, { "name": "\uc774\uc778\uaddc", "id": "560021193" }, { "name": "SunAh Han", "id": "589325702" } ] }';
var obj = JSON.parse(str);
Solution 2:
var dataString = "{/* SOMETHING */}"
var obj = eval("(" + dataString + ")");
Post a Comment for "How Can I Convert Json Text To Json Object?"