Challenge: Adding a Custom Gson Deserializer

The JSON response from Flickr contains multiple layers of nested data (Figure 24.6). In the section called Deserializing JSON text into model objects, you created model objects to map directly to the JSON hierarchy. But what if you did not care about the data in the outer layers? Wouldn’t it be nice to avoid cluttering your codebase with unnecessary model objects?

By default, Gson maps all of the JSON data directly to your model objects by matching Kotlin property names (or @SerializedName annotations) to JSON field names. You can customize this behavior by defining a custom

For this challenge, implement a custom deserializer to strip out the outermost ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.