Java 使用JsonReader读取json url
我正在尝试使用JsonReader!读取json url!。一旦我打电话给reader.beginArray,我会得到: java.lang.IllegalStateException:应为BEGIN_数组,但为字符串 这是json url:Java 使用JsonReader读取json url,java,android,json,Java,Android,Json,我正在尝试使用JsonReader!读取json url!。一旦我打电话给reader.beginArray,我会得到: java.lang.IllegalStateException:应为BEGIN_数组,但为字符串 这是json url: 我做错了什么?既然您有包含内容的html,为什么不尝试使用jsoup从html获取json作为字符串呢。它非常简单,需要的代码更少: Document d; String url="your_url"; d = Jsoup.conn
我做错了什么?既然您有包含内容的html,为什么不尝试使用jsoup从html获取json作为字符串呢。它非常简单,需要的代码更少:
Document d;
String url="your_url";
d = Jsoup.connect(url).get();
Element p = d.select("body p").first(); // fetch from p tag content
String jsonString = p.text();
? lat=-41.278407655948&lng=174.77938892631我刚刚检查了您的端点,响应不是JSON,而是一个html页面,其中包含JSON。这就是为什么您要向jsonReader传递一个字符串。您的url是一个网页,而不是JSON,请尝试使用rest客户端作为导航器,这是检查web服务的最佳方法。有没有办法从这个JSON字符串获取jsonReader
Document d;
String url="your_url";
d = Jsoup.connect(url).get();
Element p = d.select("body p").first(); // fetch from p tag content
String jsonString = p.text();