isLery
isLery

Reputation: 1

Parsing json that has unneeded fields with Moshi

Probably a stupid question, but what is the most efficient way for Moshi to parse json which contains the fields I won't use?

For example

{
  "name": "Edward",
  "surname":"Elric",
  "height": 165
}

and I won't use a "height" inside an app.

Should I create a data class with all 3 fields and mark "height" @Json(ignore = true) or @Transcient?

Or should I just create a data class with 2 fields?

Which is more efficient and proper way?

Upvotes: 0

Views: 227

Answers (1)

Serge
Serge

Reputation: 43930

If you don't need propery high at all, it is more efficient to create a class with 2 properties only - name and surname. The instance will take less memory

Upvotes: 1

Related Questions