一般我们在解析JSON字符串,都 要写上一堆解决方法,于是就着手写一个通用的解析模板,不多说了,上代码:
str={"success":true,"data":[{"level":4,"cotnent":"评asdfff意!","time":"2013-02-27 07:21:48","explain":"","memberId":"y**f"},{"level":4,"cotnent":"评价方未asfsf认满意!","time":"2013-02-27 07:21:48","explain":"","postMemberId":"y**f"}]}=
基础类

解析出来的结果类

通用解析类:

使用:
CmmonListJson json= GsonUntil.fromListJson(str,Common.class)
如:{"success":true,"data":{"level":4,"cotnent":"评asdfff意!","time":"2013-02-27 07:21:48","explain":"","memberId":"y**f"}}
解析结果类:

使用:
CommonJson j=GsonUntil.fromJson(str,Common.class);
其它格式的基本就类似,只需要换基类就可以了
网友评论