如果我想用里面的stories数组,要怎么解析?
我定义好了一个News类和Story、TopStory两个内部类,然后写了下面的代码,不行。
Gson gson = new Gson();
storiesList = gson.fromJson(JSONData, new TypeToken<List<News.Story>>(){}.getType());
刚学,网上搜也没找到解决
PHP中文网2017-04-17 18:01:22
public class Story {
String title;
String[] image;
String ga_prefix;
int type;
int id;
//setter & getter
}
public class Response {
String date;
List<Strory> stories, top_stories;
//setter & getter
}
Goson goson = new Goson()
Response res = goson.fromJson(jsonData, Response.class);
兩個類別就搞定了,上邊是偽代碼