これは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"));
}
評価まで取得していますが、全体、納期、割引、一致する説明、一致する写真、梱包、価格などの評価内のコンテンツも取得したいのですが、名前も取得したかったのです。