GSON deserialization ignore empty objects in list

Viewed 3665

A client has decided to start sending empty JSON objects at the end of arrays (to help their caching facepalm) but this has caused a whole bunch of unexpected behaviour in my app.

For example this is the data I am being sent...

[{object}, {object}, {}, {object}]

I currently use GSON to deserialize data sent from the server. I have been looking into type adapters to filter out these empty objects, however I am not fully sure how to implement the filtering. Any ideas on how to skip empty objects using GSON?

2 Answers
Related