DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

Jackson, JSON and the Proper Handling of Unknown Fields in APIs

4 years ago dzone.com

Summary: This is a summary of an article originally published by the source. Read the full original article here →

by Imagine the following scenario: You have an application that integrates with another through the consumption of REST endpoints.

To paraphrase, and correct myself: whenever there is a property in JSON that has not been mapped to its java / DTO object, Jackson will throw this exception, *unless you tell Jackson that he can ignore such attributes*.

Setting up the object mapper will tell Jackson to ignore unknown attributes in all deserializations where that object mapper is used.

The JSON below will be used, which has the age attribute that is not known by the DTO.

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com