json 解析并存储在 Phonegap 中的数组列表中

发布于 2024-12-08 20:52:53 字数 1863 浏览 0 评论 0原文

在我的应用程序中,当用户单击按钮时,它会点击一个 url,我用来获取 json 格式的返回数据,如下所示

{
  "Status":
        {
            "image":
            [ 
                { 
                    "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316145577.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316145577.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316146270.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316146270.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316146473.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316146473.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316147003.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316147003.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316581422.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316581422.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316694587.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316694587.jpg" 
                } 
            ]
        }
} 

我想要进行 json 解析并将在 Large 下命名的 URL 存储在数组中,并在 Array 下存储命名的 URL小到可以存储在另一个数组中。我希望使用 javascript 来完成此操作。

例如,在我的应用程序中的另一个网址中,我的 json 数据如下所示

{"Status":[{ "Id": "46", "Username": "guru" }]} 

为此,我使用将数据获取为

var data = JSON.parse(my_JSON_object);

var id = data.Status[0].Id;
var name = data.Status[0].Username;

但如何解析首先提到的 json 数组。 怎么办,请朋友们帮忙

in my app when the user clicks a button, it hits an url and i use to get a return data in json format as follows

{
  "Status":
        {
            "image":
            [ 
                { 
                    "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316145577.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316145577.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316146270.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316146270.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316146473.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316146473.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316147003.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316147003.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316581422.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316581422.jpg" 
                }, 
                {   "Large" : "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316694587.jpg", 
                    "Small" : "http://XXXXXXXXXXXXXXXXXX.com/images/thumb70/1316694587.jpg" 
                } 
            ]
        }
} 

i want to do json parsing and store the URLs named under Large to be stored in an Array and URLs named under Small to be stored in another array. I want this to be done using javascript.

For example in my app in another url my json data is to be as follows

{"Status":[{ "Id": "46", "Username": "guru" }]} 

For this i use to get the data as

var data = JSON.parse(my_JSON_object);

var id = data.Status[0].Id;
var name = data.Status[0].Username;

But how to parse for the json array mentioned first.
How to do this, pls help me friends

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍风燃霜 2024-12-15 20:52:53

我通过这种方式得到了答案

var data = JSON.parse(my_JSON_object);

                    var image = [];
                    for(var i=0; i< image.length(); i++)
                    {   
                        image[i] = data.Status.image[0].Large;
                        alert(image);
                    }
                        alert(image);

i got the answer by this way

var data = JSON.parse(my_JSON_object);

                    var image = [];
                    for(var i=0; i< image.length(); i++)
                    {   
                        image[i] = data.Status.image[0].Large;
                        alert(image);
                    }
                        alert(image);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文