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 …

Running a PowerShell script in Dockerfile

Recently we needed to create a Docker image that provided multiple command line tools as part of our CI/CD pipeline. As part of our pipeline we use PowerShell Core to run scripts, triggering changes within our AWS infrastructure, this means installing the AWS SDK module into the Docker image so we don’t have to download it on every single use. …

Running a pod in EKS with Service Accounts, AWS SDK 2

EKS is a brilliant feature from AWS, providing a mostly managed Kubernetes cluster that you can deploy your own services to. If you’re running in AWS you’ll likely be using multiple services such as S3, DynamoDB, SQS, etc. All of these services require credentials to gain access. The best practice is to ensure your code only has permissions to do …

Add a mapping from Interface to Concrete type with Moshi and Kotlin

If you’re using Moshi for your JSON needs, you’ll eventually stumble upon the need to specify the concrete implementation of an interface. For example, you might have a contrived example such as: So how do we make sure the list of mammals in MammalList uses the concrete Human implementation? With a custom adapter! The implementation is simple – we just …

Binding Annotations with Guice and Kotlin

If you’re using kotlin-guice to use Guice with your Kotlin project, you might have run into problems with binding annotations. Annotations let you use a specific implementation of an interface when there are multiple implementations registered with Guice: The problem is Kotlin works slightly differently when it comes to annotations and figuring out how to make it work can be …