码迷,mamicode.com
首页 > 其他好文 > 详细

GSON解析

时间:2016-04-08 18:22:49      阅读:305      评论:0      收藏:0      [点我收藏+]

标签:

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;
}

 

GSON解析

标签:

原文地址:http://www.cnblogs.com/anni-qianqian/p/5368974.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!