说到Json解析库,网上可以说一找一大堆,Json解析库确实是大部分程序员都会使用的一类库,虽然自己完全可以一步步去解析,但是其实真的没必要自己去写,不会偷懒的程序员不是好程序员。
说到moshi,可能很多童鞋没听过,但是说到square团队,大家基本上都是听说过的,moshi就是该团队出品的一个Json解析库。
地址是:https://github.com/square/moshi
这里写下最基本简单的使用:
首先是compile:
compile 'com.squareup.moshi:moshi:1.2.0'
国际惯例,根据Json字符串的格式建立实体(您可以纯手写或者使用GsonFormat等等):
public final class IdCard {
private String resultcode;
private String reason;
private ResultBean result;
public String getResultcode() {
return resultcode;
}
public void setResultcode(String resultcode) {
th