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Qn7TfXMoPZ5jt/75XA/SsJ76ZjkMFJ67VAqF42HBGMeoqJj71VkZuTHG6mdyzSv6D5jQt3MpyJHH0Y1AeTQcqMmnYRv6Vd2F5cJaaxGpglOwXMahZISejZH3h6g5q2sM+jaxPo+oSYEL7d68jHZh6gjmuXTJOa7PWmF/wCHdD1knM3ltZXB7lo/un/vk0OKe44ycXdFDV9LWQ5ivLUkHALsUB/EjH61zU1s8DkSbCRxlHDD8xXbWOn3uvRiztJ44w2HcyvtTA4OTXMa5pv9najLCGiLKcMI5A6g98N3FCjYJO71MoH2ooFFMkniQb2Q8EGta1uprd44zwgbj2zWZCD5xJ7nPNaF1bGKBZVPy9RzSeqGnZnrnhO4Fxbkk89B9K62AM7hVBYnoAMk1yHg+2h0HwtHrHiCV7SCcA28GMzT+m1e31NZ+ufFG7WN4dNjXTIOgWAhpm/35D0+i/nXH7Jt6nd7Wy0PUmWHT1VtQuoLXd91ZXG8/RetSXup6bYwCVpHmTGd4O1PpnH9a+fLTW7zULwlpCm45YhiWP1Y81794I1vRpvCtpp4vbSa5QENAZAzElvQ10xpRSOadWTOH134lJAsiaeyxv8AwvFArH823fpXCXvxD1u6JV9Y1XB7LMEH5KK+itd8L+HdRjVb/R4JA7f6yNQjA/UYNfLXimxt9O8SX1pbZEEUzKgJ5AzxVuMTNTaN638c6qmltaQ7ZZS283E4Lykem4ngfhXbaJr1r4w8I6hbCSSw1i0h3qYpyolA9Qf1rzHUtCuNEsNNvxN5iXlstxlBwmS"}],"response":"success"}

次のコードを使用しています。

 JSONObject objResponse=new JSONObject(retResult);
 final String strResponse=objResponse.getString("response");
 if(strResponse!=null && strResponse.equalsIgnoreCase("success")){
     //it get inside the loop-->
     final String image=objResponse.getString("imageUrl");
 }

imageUrl は Base64 でエンコードされた文字列です。

次のエラーが表示されます。

org.json.JSONException: No value for imageUrl

どうすればこれを修正できますか?

4

2 に答える 2

1

json配列があります。あなたはそれをスキップします。私はそれが次のようであるべきだと思います:

JSONObject objResponse=new JSONObject(retResult);
JSONArray basicDetailsList = objResponse.getJSONArray("basicDetailsList");
JSONObject actualObject = basicDetailsList[0];
String response = actualObject.getString("response");

if(response.equals("success"))
    String imageURL= actualObject.getString("imageUrl");

このコードは試していません。タイプミスがあるかもしれません。

于 2013-09-11T13:10:25.993 に答える