Search code examples
jsonmoshi

Moshi ignore field


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


Solution

  • 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.