私は彼のJSONを持っていると私は変数images
からの画像の配列を取得する必要があります。..jsonからこのイメージの配列をどのように取得できますか?
この私のJSON:私は、この画像の配列を取得し、グリッドに表示したい
{
id: 215,
title: " this is title",
image: "1464958558.jpg",
description: "description",
images: "["1464958558.jpg","1464958559.jpg","1464958561.jpg","1464958563.jpg","1464958564.jpg","1464958568.jpg","1464958569.jpg","1464958570.jpg","1464958573.jpg","1464958574.jpg"]",
user_name: "user name",
telephone: ""
}
ビューは...と私はlogcat
私doInBackGround()のいずれかの応答を見つけることができません
@Override
protected Integer doInBackground(String... arg0) {
// Building Parameters
HttpHandler sh = new HttpHandler();
// Making a request to url and getting response
ID = mCursor.getString(ArticleLoader.Query._ID);
String jsonStr = sh.makeServiceCall(String.valueOf(Config.BASE_URL));
//jsonStr = sh.makeServiceCall(url + 373); //or url + ID
Log.i(TAG, "doInBackground Image: " + String.valueOf(Config.BASE_URL));
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
GridItem item;
item = new GridItem();
Log.i(TAG, "parseResult: " + jsonObj);
for (int i = 0; i < jsonObj.length(); i++) {
// if (response != null) {
String images = jsonObj.getString("images");
item.setImage(IMAGE_LINK + images);//IMAGE_LINK +
Log.i(TAG, "parseResult: " + IMAGE_LINK + " " + images);
mGridData.add(item);
}
} catch (JSONException e1) {
e1.printStackTrace();
}
}
return null;
}
用量は正しくデータを取得しますか?
イメージjsonオブジェクトは文字列かjson配列ですか?あなたのコードでは文字列です。 –
@NarutoUzumaki jsonの私の括弧は二重qutetionから外に ""あるべきですか? – CODE1010101010101
まさに、json配列として解析できます。 –