0

我的代码在“主菜”数组中没有得到 json 对象请帮帮我,我的代码没有装在 json 数组“主菜”中:{ 值检查我的代码是否正确访问???我的代码在这行之后没有进入 JSONArray school = data.getJSONArray("entre");

                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"}
 }
  }
 }
4

1 回答 1

0

嗨,主菜是一个对象,而不是一个数组使用 getjsonobject("entree");

于 2013-08-15T13:38:37.030 回答