Skip to content
Advertisement

Jackson JsonRootName doesn’t add any root value

I am serialising an object, which I’d like to put a root value for.

This is my class.

JavaScript

This is how I am serialising it:

JavaScript

But the serialised value is:

JavaScript

While I was hopping to have a root json value as fed in the class definition.

Could you help with that please?

Advertisement

Answer

JavaScript

Output:

JavaScript

You need to enable WRAP_ROOT_VALUE on the object mapper

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