Converting JSON into models using Jackson

There are many efficient and accurate libraries that serve as an ORM and bind your JSON response to a model. Jackson is one of them. Google's GSON and Square.io's Moshi are some popular libraries.

In a static lambda function, there is the mapper.writeValue line. A mapper object is defined in a separate file named Mapper.kt. And the file has the following source code:

val mapper = jacksonObjectMapper().apply { setSerializationInclusion(JsonInclude.Include.NON_NULL) }

Get Hands-On Serverless Applications with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.