无法使用Volley解析JSON对象 [英] Unable to parse JSON object using Volley

查看:75
本文介绍了无法使用Volley解析JSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSON文件:

JSON文件URL

我正在遍历"biller"数组以获取"billerCategory"所在的所有对象: 电".我正在尝试获取"paramName"值.但是我只得到3个paramName值.

i am looping through the "biller" Array to fetch all the object's where "billerCategory": is "Electricity". I am trying to get "paramName" value. But i am only getting 3 paramName values.

响应:

代码:

try {
                JSONArray biller = response.getJSONArray("biller");

                Log.d(TAG, biller.toString());

                // Loop through biller Array and find billerID
                for (int i = 0; i < biller.length(); i++)
                {
                    JSONObject billerObj = (JSONObject) biller.get(i);
                    String category = billerObj.getString("billerCategory");


                    //Log.d(TAG, category);

                    if (category.equalsIgnoreCase("Electricity")){

                        JSONObject paraminput = billerObj.getJSONObject("billerInputParams");
                        JSONObject paramInfo = paraminput.getJSONObject("paramInfo");
                        String paramName = paramInfo.getString("paramName");


                        Log.d(TAG, paramName);

                    }
                }
            } 

推荐答案

发生了异常.搜索"TORR00000SUR04".碰巧"paramInfo"在那时是一个JSONArray.

An exception has occured. Search for 'TORR00000SUR04'. It happened that "paramInfo" is an JSONArray at that point.

这篇关于无法使用Volley解析JSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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