オブジェクトを持たないjsonを取得しようとすると、うまくいきます。しかし、オブジェクトを持つjsonを取得しようとすると、エラーが発生します。
アイデアはありますか?
protected Void doInBackground(String... params) {
String url = "http://example.com/adchara1/";
JSONArray data = null;
try {
JSONObject jsonObject = new JSONObject(result);
MyArrList = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> map;
data = jsonObject.getJSONArray("countries");
data = new JSONArray(getJSONUrl(url));
for (int i = 0; i < data.length(); i++) {
JSONObject c = data.getJSONObject(i);
map = new HashMap<String, Object>();
// Thumbnail Get ImageBitmap To Object
map.put("photo", (String) c.getString("photo"));
map.put("ImageThumBitmap",(Bitmap) loadBitmap(c.getString("photo")));
// Full (for View Popup)
map.put("frame", (String) c.getString("frame"));
MyArrList.add(map);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
エラー
12-26 11:51:10.352: W/System.err(23284): org.json.JSONException: End of input at character 0 of
12-26 11:51:10.368: W/System.err(23284): at org.json.JSONTokener.syntaxError(JSONTokener.java:450)
12-26 11:51:10.368: W/System.err(23284): at org.json.JSONTokener.nextValue(JSONTokener.java:97)
12-26 11:51:10.368: W/System.err(23284): at org.json.JSONObject.<init>(JSONObject.java:154)
12-26 11:51:10.368: W/System.err(23284): at org.json.JSONObject.<init>(JSONObject.java:171)
12-26 11:51:10.376: W/System.err(23284): at com.example.gridview.MainActivity$DownloadJSONFileAsync.doInBackground(MainActivity.java:180)
12-26 11:51:10.376: W/System.err(23284): at com.example.gridview.MainActivity$DownloadJSONFileAsync.doInBackground(MainActivity.java:1)
12-26 11:51:10.376: W/System.err(23284): at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-26 11:51:10.376: W/System.err(23284): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-26 11:51:10.376: W/System.err(23284): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-26 11:51:10.376: W/System.err(23284): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-26 11:51:10.376: W/System.err(23284): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
12-26 11:51:10.376: W/System.err(23284): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
12-26 11:51:10.376: W/System.err(23284): at java.lang.Thread.run(Thread.java:856)
12-26 11:51:10.399: D/libEGL(23284): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
12-26 11:51:10.423: D/libEGL(23284): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
12-26 11:51:10.430: D/libEGL(23284): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
12-26 11:51:10.516: D/OpenGLRenderer(23284): Enabling debug mode 0
12-26 11:51:10.735: D/AndroidRuntime(23284): Shutting down VM
12-26 11:51:10.735: W/dalvikvm(23284): threadid=1: thread exiting with uncaught exception (group=0x4158f300)
12-26 11:51:10.735: E/AndroidRuntime(23284): FATAL EXCEPTION: main
12-26 11:51:10.735: E/AndroidRuntime(23284): java.lang.NullPointerException
12-26 11:51:10.735: E/AndroidRuntime(23284): at com.example.gridview.MainActivity$ImageAdapter.getCount(MainActivity.java:122)
12-26 11:51:10.735: E/AndroidRuntime(23284): at android.widget.GridView.setAdapter(GridView.java:182)
12-26 11:51:10.735: E/AndroidRuntime(23284): at com.example.gridview.MainActivity.ShowAllContent(MainActivity.java:91)
12-26 11:51:10.735: E/AndroidRuntime(23284): at com.example.gridview.MainActivity$DownloadJSONFileAsync.onPostExecute(MainActivity.java:209)
12-26 11:51:10.735: E/AndroidRuntime(23284): at com.example.gridview.MainActivity$DownloadJSONFileAsync.onPostExecute(MainActivity.java:1)
12-26 11:51:10.735: E/AndroidRuntime(23284): at android.os.AsyncTask.finish(AsyncTask.java:631)
12-26 11:51:10.735: E/AndroidRuntime(23284): at android.os.AsyncTask.access$600(AsyncTask.java:177)
12-26 11:51:10.735: E/AndroidRuntime(23284): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
12-26 11:51:10.735: E/AndroidRuntime(23284): at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 11:51:10.735: E/AndroidRuntime(23284): at android.os.Looper.loop(Looper.java:137)
12-26 11:51:10.735: E/AndroidRuntime(23284): at android.app.ActivityThread.main(ActivityThread.java:4931)
12-26 11:51:10.735: E/AndroidRuntime(23284): at java.lang.reflect.Method.invokeNative(Native Method)
12-26 11:51:10.735: E/AndroidRuntime(23284): at java.lang.reflect.Method.invoke(Method.java:511)
12-26 11:51:10.735: E/AndroidRuntime(23284): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
12-26 11:51:10.735: E/AndroidRuntime(23284): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
12-26 11:51:10.735: E/AndroidRuntime(23284): at dalvik.system.NativeStart.main(Native Method)
12-26 11:51:12.509: I/Process(23284): Sending signal. PID: 23284 SIG: 9