Skip to content
Advertisement

How to get Jackson To Throw An Error on Incorrect Casing On Deserialization

I have the following class:

JavaScript

and my mapper looks as follows:

JavaScript

Today, if someone messes up their json object for example messing up the capitalization on client:

JavaScript

it will deserialize client to null. I’d like it to error because the casing is wrong. (And for any key that’s passed in with bad casing).

Is there a way to do this with config? If no, how?

Advertisement

Answer

You can accomplish this in your yaml.

JavaScript

Not sure why the object mapper wasn’t hooking up.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement