檢索對象我有這樣Android的JSON從URL
{"a":"something","b":"something"}
{"a":"something1","b":"something1"}
腳本返回JSON這是NDJSON響應! 現在我試圖從android中檢索它,但是我在jsonResult上得到了null。 這是我使用的代碼讀取後:
JSONObject jsonResponse = new JSONObject(jsonResult);
JSONArray jsonMainNode = new JSONArray(jsonResponse);
我得到的第一行空指針異常,因爲jsonResult爲空。 有什麼不對?
這是我如何獲取:
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
jsonResult = inputStreamToString(
response.getEntity().getContent()).toString();
你可以發佈你的'jsonResult'?你有這個錯誤,因爲'jsonResult'爲null – ThomasThiebaud
發佈了更多的代碼..你能分析哪些是錯誤的嗎? –
也許發佈此方法將幫助我們瞭解更多'inputStreamToString' – kabuto178