我只是尝试使用 GSON 解析给定的 URL,但遇到了一些问题。
网址
http://api.flickr.com/services/feeds/photos_public.gne?format=json
jsonFlickrFeed({
"title": "Uploads from everyone",
"link": "http://www.flickr.com/photos/",
.....)
Json 响应是这样的。其中包含一个 ({ 在字符串的开头,这会导致解析出现问题。
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1
我的模型类如下所示:
public class Flicker {
public JsonFlickrFeed jsonFlickrFeed;
public JsonFlickrFeed getDealList() {
return jsonFlickrFeed;
}
public static class JsonFlickrFeed{
public String title;
public String link;
public String description;
public String modified;
public String generator;
public List<Items> items = new ArrayList<Flicker.Items>();
}
public static class Items {
public String title;
public String link;
public String media;
public String date_taken;
public String description;
public String published;
public String author;
public String author_id;
public String tags;
}
}