1

What's the equivalent of the annotation @JsonIgnoreProperties(ignoreUnknown = true) for Moshi? Does it ignore unknown properties by default or not?

Bencri
  • 1,173
  • 1
  • 7
  • 22

1 Answers1

3

Moshi by default ignore's properties that are not declared in POJO's and are present in JSON without throwing any error.

Incase failure is desired in such case, failOnUnknown has to be set explicitly on the adapter.

For e.g. Moshi.Builder().build().adapter(MyClass::class.java).failOnUnknown()

farhan patel
  • 1,490
  • 2
  • 19
  • 30