如何获得在Android的/ Java中的JSON对象中的JSON阵列的各个标签名称的列表阵列、如何获得、象中、名称

2023-09-06 23:36:34 作者:你如妖孽般勾走我的魂

我有一个小问题解析JSON响应,因为它得到更新不断保持每当我送request.All我所看到的让我们提供标签名的例子。我的问题是,我想从通过API发送的请求解析的数据,我想列出所有JSON阵列的所有现有的JSON对象中的标签之前,我开始分析。是否有可能在机器人。 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);
        }
    }