检索对象我有这样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