如何获得在Android的/ Java中的JSON对象中的JSON阵列的各个标签名称的列表 [英] How to get the list of all tag names of json arrays within a json object in android/java

查看:270
本文介绍了如何获得在Android的/ Java中的JSON对象中的JSON阵列的各个标签名称的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题解析JSON响应,因为它得到更新不断保持每当我送request.All我所看到的让我们提供标签名的例子。我的问题是,我想从通过API发送的请求解析的数据,我想列出所有JSON阵列的所有现有的JSON对象中的标签之前,我开始分析。是否有可能在机器人。 <一href="http://api.yamgo.tv/channel?apiKey=187abeefc53f900600dc0fc5b8f913a0&token=892e069fa48eead5e7f84cddafe7f0ba" rel="nofollow">http://api.yamgo.tv/channel?apiKey=187abeefc53f900600dc0fc5b8f913a0&token=892e069fa48eead5e7f84cddafe7f0ba 这是我送的要求,这给了我一个JSON响应。其中有渠道作为一个JSON对象,它的许多JSON阵列标签,如宝莱坞,娱乐,音乐等内。使用在线分析器的响应检查出来。我想数组名称的列表。我怎样才能做到这一点。任何人都可以请帮助。谢谢你。

I have a small problem parsing json response because it constantly keeps on getting updated whenever i send a request.All the examples I have seen makes us provide the tag name. My question is that I am trying to parse data from a request sent through an API and I want to list out all the tags of all JSON Arrays existing within a JSON Object before I start parsing. Is it possible in android. http://api.yamgo.tv/channel?apiKey=187abeefc53f900600dc0fc5b8f913a0&token=892e069fa48eead5e7f84cddafe7f0ba This is the request I am sending and it gives me a json response. which has channels as a json object and within it many json arrays with tags like bollywood, entertainment, music,etc. Use an online parser for the response to check it out. I want this list of array names. How can I do it. Could anyone please help. Thanks.

推荐答案

其实,我理解了它与我的一个朋友一个小的帮助。需要使用iterator对象。 这里是code中的片段

I actually figured it out with a small help from one of my friend. Needed the use of Iterator object. Here is the snippet of code

JSONObject channels = jobj.getJSONObject(TAG_CHANNELS);
    Iterator<?> keys=channels.keys();
    while( keys.hasNext() )
    {
        String key = (String)keys.next();
        Log.e("Key", key);
        if( channels.get(key) instanceof JSONArray ){
            jsontags.add(key);
        }
    }

这篇关于如何获得在Android的/ Java中的JSON对象中的JSON阵列的各个标签名称的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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