私は現在アンドロイド用に開発中で、一部の顔認識サービスを使用しています。このサービスは、以下に示すような複雑なJSONを返します。アンドロイドでの複雑なJSON解析 - マルチオブジェクトと配列
EDIT - 適切なJSON
{"photos":[{"url":"http:\/\/face.com\/images\/ph\/0b3ecef9a00b647570027e590b72c893.jpg","pid":"[email protected]_88f17d8482a3d3aac1d07b3062a3e29b","width":960,"height":637,"tags":[{"tid":"[email protected]_88f17d8482a3d3aac1d07b3062a3e29b_54.06_45.53_1_1","recognizable":true,"threshold":59,"uids":[{"uid":"[email protected]","confidence":17}],"gid":null,"label":"","confirmed":false,"manual":false,"tagger_id":null,"width":19.58,"height":29.51,"center":{"x":54.06,"y":45.53},"eye_left":{"x":49.55,"y":38.8},"eye_right":{"x":58.4,"y":38.92},"mouth_left":{"x":49.82,"y":52.1},"mouth_center":{"x":54.77,"y":53.04},"mouth_right":{"x":58.36,"y":52.16},"nose":{"x":54.98,"y":46.3},"ear_left":null,"ear_right":null,"chin":null,"yaw":-7.59,"roll":2.27,"pitch":0.01,"attributes":{"age_est":{"value":18,"confidence":30},"age_max":{"value":24,"confidence":30},"age_min":{"value":12,"confidence":30},"face":{"value":"true","confidence":99},"gender":{"value":"female","confidence":41},"glasses":{"value":"false","confidence":73},"lips":{"value":"parted","confidence":63},"mood":{"value":"happy","confidence":61},"smiling":{"value":"true","confidence":48}}}]}],"status":"success","usage":{"used":1,"remaining":4999,"limit":5000,"reset_time_text":"Wed, 28 Mar 2012 14:20:08 +0000","reset_time":1332944408}}
私はそれから抜け出すために必要な唯一のものは、UIDの配列内のUID値です。成功しなかったいくつかの方法を試したことがありますか?
EDIT - 答え:)
String uid = new JSONObject(inputString).getJSONArray("photos").getJSONObject(0).getJSONArray("tags").getJSONObject(0).getJSONArray("uids").getJSONObject(0).getString("uid");
これらの ' - '文字は正しくないのですか? – Ferdau
あなたは正しいことを申し訳ありませんが、読みやすいように思われます。 – user1298268
あなたが試したことを投稿し、あなたが使っているjsonparserを –