Moshi Adapters for Platform Types like ArrayList and LinkedList (Part 2)

Earlier we created a generic adapter that supported concrete collection types in Moshi. However, sometimes the type of the item within the collection isn’t available. We’ll need to create another adapter but there is a problem – Java type erasure. Even though we might know the type ahead of time in the code, by the time we get to runtime …

Moshi Adapters for Platform Types like ArrayList and LinkedList (Part 1)

If you’ve used Moshi for any length of time, you’ve probably come across an error like: Platform class java.util.ArrayList (with no annotations) requires explicit JsonAdapter to be registered This means Moshi can’t serialise or deserialise the collection because it’s not just a basic ‘List’. The error message tells you to create a custom JsonAdapter but the documentation doesn’t really tell …