我的代码没有在“entree”数组中获得json objet请帮助我 我的代码没有shoewinside json数组“entree”:{值检查我的代码是否正确访问???我的代码在此行JSONArray school = data.getJSONArray(“entree”)之后不进去;
JSONObject json = new JSONObject(str);
JSONObject json2 = new JSONObject(str);
message = json2.getString("message");
status = json2.getString("status");
if (status.equals("1")) {
JSONObject data = json.getJSONObject("data");
JSONArray school = data.getJSONArray("entree");
JSONObject jsonOrder = (JSONObject) school.get(0);
txt1.setText(jsonOrder.getString("id"));
txt2.setText(jsonOrder.getString("name"));
txt3.setText(jsonOrder.getString("description"));
String url1 = jsonOrder.getString("image");
imgLoader.DisplayImage(url1, img1);
{
"status":1,
"message":"",
"data":
{
"entree":{
"id":32,
"name":"Cheese Burger",
"description":"Lorem ipsum.",
"image":"http:\/\/198.57.208.46\/~school\/images\/android\/cheese-burger.png",
"contains":
[
{
"name":"Cheese",
"image":"http:\/\/198.57.208.46\/~school\/images\/android\/cheese1.png"
}
,
{
"name":"Tomato",
"image":"http:\/\/198.57.208.46\/~school\/images\/android\/tomato.png"
}
,
{
"name":"Bread",
"image":"http:\/\/198.57.208.46\/~school\/images\/android\/bread.png"
}
]
,
"nutritions":
{
"Calories":"150",
"Carbohidrates":"16g"}
}
}
}
答案 0 :(得分:0)
嗨entree是一个对象而不是数组使用getjsonobject(“entree”);