1.把GSON.jar包放到工程lib目录下并依赖
2.使用HiJSON工具格式化json字符串
2.创建对象类
public class MyNews {
public News_Paramz paramz;
public String status;
public class News_Paramz{
public int PageIndex;
public int PageSize;
public long TotalCount;
public int TotalPage;
public List<News_feeds> feeds;
public class News_feeds {
public String category;
public String id;
public String oid;
public Data data;
public class Data{
public String changed;
public String cover;
public String format;
public String pic;
public String subject;
public String summary;
}
}
}
}
3.使用GSON解析
public static MyNews parseGson(String json) {
MyNews myNews = null;
if (json == null) {
return null;
}
Gson gson = new Gson();
myNews = gson.fromJson(json, MyNews.class);
return myNews;
}