Android org.json.JSONException:从json对象中查找特定字符串

Android org.json.JSONException:从json对象中查找特定字符串,android,json,Android,Json,我在Android中工作,从互联网上找到了json,如下所示: JSONObject childObject=me.getJSONObject(pos); String fisrtkey=childObject.getString("A"); JSONArray jsonArray=childObject.getJSONArray("c"); 我想找到A中的C21。请参阅来自请求的json。 有人能帮我吗?试试这个: JSONObject j = new JSONObject(data); J

我在
Android
中工作,从互联网上找到了
json
,如下所示:

JSONObject childObject=me.getJSONObject(pos);
String fisrtkey=childObject.getString("A");
JSONArray jsonArray=childObject.getJSONArray("c");
我想找到
A
中的
C21
。请参阅来自请求的
json
。 有人能帮我吗?

试试这个:

JSONObject j = new JSONObject(data);
JSONArray c = j.getJSONArray("me");
for(int n = 0; n < c.length(); n++) {
    JSONObject person = (JSONObject) c.get(n );
    String id = person.getString("A"); 
    ...
}
JSONObject j=新的JSONObject(数据);
JSONArray c=j.getJSONArray(“me”);
对于(int n=0;n
您在解析时错过了这个json数组。首先从该json对象获取该值,然后获取MEjson数组。像这样的

    JSONObject j = new JSONObject(data);
    JSONArray c = j.getJSONArray("This");
    JSONObject j1 = c.getJSONArray(0);
    JSONArray d = j.getJSONArray("me");
    for(int n = 0; n < c.length(); n++) {
        JSONObject item = c.getJSONObject(n);
        System.out.println(item.getString("A"));
                    }
JSONObject j=新的JSONObject(数据);
JSONArray c=j.getJSONArray(“本”);
JSONObject j1=c.getJSONArray(0);
JSONArray d=j.getJSONArray(“我”);
对于(int n=0;n
试试看{
JSONObject j=新的JSONObject(数据);
JSONArray c=null;
c=j.getJSONArray(“本”);
JSONObject项=c.getJSONObject(0);
JSONArray me=item.getJSONArray(“me”);

对于(int pos=0;pos),为什么会有difference@Anantham它给出了异常
org.json.JSONException:No value for me
当你解析“this”json数组时,在we have“me”中,你能发布完整的解析代码吗@waqasWhat是循环中
item
的值?无效的JSON…复制并粘贴JSON到jsonlint.com上,并检查其validity@TimCastelijns程序甚至没有找到
me
giving exception
org.json.jsoneexception:No value for me
如果您只想找到json中的字符串,为什么不使用简单的java方法呢.lang.String.contains()并使用它来检查它是否存在。您给了我方向。这不是括号问题。这是y概念问题。谢谢老兄。
try {
        JSONObject j=new JSONObject(data);
        JSONArray c= null;
        c = j.getJSONArray("This");
        JSONObject item=c.getJSONObject(0);
        JSONArray me=item.getJSONArray("me");

        for(int pos=0;pos<me.length();pos++)
        {

            JSONObject childObject=me.getJSONObject(pos);
            String fisrtkey=childObject.getString("A");
            JSONArray jsonArray=childObject.getJSONArray("c");
        }



    } catch (JSONException e1) {
        e1.printStackTrace();
    }