Moshi ignore field

人走茶凉 提交于 2019-12-10 02:51:56

问题


Is there a simple way to ignore a field when using moshi to serialize to a json string? I can only think about is a custom adapter - but I have the feeling that there is a better way


回答1:


Use transient on the field declaration.

private transient String your_variable_name;

Originally I found Exclude fields from serialization and deserialization

Hope It's help you.



来源:https://stackoverflow.com/questions/36204499/moshi-ignore-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!