这是 json :
{
"product_id": 1,
"reviews": [
{
"comment": "The product is good, I recommend it.",
"friend": true,
"friend_type": "friend",
"like": true,
"product_id": 1,
"ratings": {
"Overall": 3,
"delivery_time": 3,
"discounts_and_offers": 3,
"matches_description": 5,
"matches_photo": 1,
"packaging": 3,
"price": 4
},
"reviewer": {
"age": 36,
"biography": "This is the biography for Gopika Chadha (8). Xpmaamdkp Wcbmj Gwvc Rvmnthfh Ajluydcsu Iqpsrfl Tyzil Ejzntc Fv Jwuqnoye Anfletfs Uwkkotarm Eyvlugt Zctrgdpn Avck Wwhzzfhg Ao.",
"connection": "is connected with, has similar likes as and 4 more affinity with you.",
,"email": "ggananth+sgepdemo_8_gopika_chadha@gmail.com",
"friend_type": "friend",
"id": 8,
"name": "Gopika Chadha",
"sex": "female",
"timestamp": 1472621245.412491
},
"self_review": false,
"title": "It is awesome",
"usefulness": 10,
"user_id": 8,
"viewer_useful": false
},
我试图将评级定为:
JSONObject obj = new JSONObject(result);
JSONArray reviewsArray=obj.getJSONArray("reviews");
for (int i=0;i<reviewsArray.length();i++) {
JSONObject reviewsObj = reviewsArray.getJSONObject(i);
rList.setComment(reviewsObj.optString("comment"));
rList.setTitle(reviewsObj.optString("title"));
rList.setUsefulness(reviewsObj.optInt("usefulness"));
rList.setFriend(reviewsObj.optBoolean("friend"));
JSONObject ratingsObj=new JSONObject("ratings");
rList.setOverall(ratingsObj.optInt("Overall"));
rList.setDeliveryTime(ratingsObj.optInt("delivery_time"));
rList.setDiscountsAndOffers(ratingsObj.optInt("discounts_and_offers"));
rList.setMatchesDescription(ratingsObj.optInt("matches_description"));
rList.setMatchesPhoto(ratingsObj.optInt("matches_photo"));
rList.setPackaging(ratingsObj.optInt("packaging"));
rList.setPrice(ratingsObj.optInt("price"));
}
我得到了评级,但我想获得评级中的内容,如整体、交货时间、折扣、匹配描述、匹配照片、包装和价格,我也想得到名字。