我正在"restaurant_working_hours" = (
{
close = {
day = 1;
dayName = Monday;
time = 0000;
};
open = {
day = 1;
dayName = Monday;
time = 1500;
};
},
{
close = {
day = 2;
dayName = Tuesday;
time = 0000;
};
open = {
day = 2;
dayName = Tuesday;
time = 1500;
};
},
{
close = {
day = 3;
dayName = Wednesday;
time = 0000;
};
open = {
day = 3;
dayName = Wednesday;
time = 1500;
};
},
{
close = {
day = 4;
dayName = Thursday;
time = 0000;
};
open = {
day = 4;
dayName = Thursday;
time = 1500;
};
},
{
close = {
day = 5;
dayName = Friday;
time = 0000;
};
open = {
day = 5;
dayName = Friday;
time = 1500;
};
}
);
工作,并从互联网上找到Android
,如下所示:
json
我想找到JSONObject childObject=me.getJSONObject(pos);
String fisrtkey=childObject.getString("A");
JSONArray jsonArray=childObject.getJSONArray("c");
中的C21
。请参阅来自请求的A
。
有人能帮助我吗?
答案 0 :(得分:0)
您在解析时错过了 THIS json数组。首先从那个json对象得到它,然后得到 ME json数组。像这样的东西
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"));
}
答案 1 :(得分:0)
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();
}
//希望这对你有所帮助,并且检查json是否无效,你错过了 // jsonarray“我”的支架。
答案 2 :(得分:-1)
试试这个:
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");
...
}