JSON数组转换为Javascript数组 [英] JSON array convert to Javascript array

查看:76
本文介绍了JSON数组转换为Javascript数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我在JSON中获得了输出...现在我需要将这些数据转换为javascript ..

Hi. I got my output in JSON... Now I need to convert those data into javascript..

如何在javascript中编写代码?
我必须将图像显示到浏览器..只有通过在javascript中编写代码才有可能。
帮助我..

How to write the code in javascript? I have to display the images to the browser.. it is possible only by writing the code in javascript. Help me..

我的JSON输出是..

My JSON output is..

    [{"0":"101","member_id":"101","1":"3k.png","image_nm":"3k.png","2":"\/images\/phones\/","image_path":"\/images\/phones\/"},
     {"0":"102","member_id":"102","1":"mirchi.png","image_nm":"mirchi.png","2":"images\/phones\/","image_path":"images\/phones\/"},
     {"0":"103","member_id":"103","1":"masti.png","image_nm":"masti.png","2":"images\/phones\/","image_path":"images\/phones\/"}]


推荐答案


我在 JSON 中得到了我的输出...现在我需要将这些数据转换为
javascript ..

hai i got my output in JSON...now i need to convert those data into javascript..

使用 JSON.parse() 函数,以便将其转换为JS对象。

Use JSON.parse() function in order to convert it to JS object.

var obj = JSON.parse(yourJsonString);

现在你可以使用 for-in 循环迭代其每个项目:

And now you can use for-in loop to iterate over each of its items:

for (var x in obj){
  if (obj.hasOwnProperty(x)){
    // your code
  }
}

这篇关于JSON数组转换为Javascript数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆