本文介绍了如何将JSON文本转换为JSON对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{
 "data": [
          {
             "name": "JoongBum Lee",
             "id": "526210623"
          },
          {
             "name": "\uc774\uc778\uaddc",
             "id": "560021193"
          },
          {
             "name": "SunAh Han",
             "id": "589325702"
          }
    ]
}

我有JSON数据,我想将此数据转换为javacript对象

i have JSON data and I want to convert this data in to javacript object

推荐答案

使用 JSON.parse .它是ECMAScript 5中引入的,因此< = IE7不支持.您可以找到一个 JSON库来填充对旧版浏览器的支持,或者如果您使用jQuery,则可以使用 $.parseJSON .

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);

这篇关于如何将JSON文本转换为JSON对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 07:26