Moshi reflection vs Moshi code gen Finally, a few more resources are included for those who want to give Moshi a try as well. https://proandroiddev.com/goodbye-gson-hello-moshi-4e591116231e– Good Moshi and GSON comparision https://gist.github.com/ChainsDD/07c6b52837a2fa0622c93df07a92...
Finally, we need to add the factory to the Moshi builder. What if we get a non-enum type in the response? There we have a problem, this factory will not work well then. One solution is to addUNKNOWNas a new type insideVehicleTypeand define a default value within the factory. Photo ...
但如果没有默认值的时候,kotlin生成的字节码中是没有空构造的,此时Gson就拿不到默认值了。而moshi和ks能够认出kotlin的一些特点,但是区区一个解析json都要我去处理异常,我是不高兴的。。 设置成所有参数都可空,且给一个默认值,那么moshi和Gson就都没有问题了。但是这样就放弃了kotlin的非空特性 谁的好的方法,...
Gson: com.squareup.retrofit2:converter-gson Jackson: com.squareup.retrofit2:converter-jackson Moshi: com.squareup.retrofit2:converter-moshi Protobuf: com.squareup.retrofit2:converter-protobuf Wire: com.squareup.retrofit2:converter-wire Simple XML: com.squareup.retrofit2:converter-simplexml Scalars ...