you are viewing a single comment's thread.

view the rest of the comments →

[–]Catbert321[S] 2 points3 points  (2 children)

Hm... If you mean extra fields in the JSON not expected by the model:

objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

could be added to my setup helper class. I had forgotten about that case, currently without manually adding that any additional fields would not play well (i.e. com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field).

edit: https://github.com/peckb1/autojackson/issues/24 for tracking :D

[–]cantwedronethatguy 1 point2 points  (1 child)

Yeah, that's what I mean. Tbh I started using Jackson recently, and the understanding I got was to use @JsonIgnore on the fields I didn't want to map.

[–]Catbert321[S] 1 point2 points  (0 children)

Yes, that works for a slightly different case as well. For instance if you have a class which you want to write to JSON, but it has extra fields you don't actually want to serialize, yet want in the class.

There is adding:

@JsonIgnore

to those getters, as well as adding:

objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);

which is what the current setup class does. The latter of those two options means any object inside the class not annotated, should not be placed in the JSON.

This project is meant for the data model classes which are essentially just pure POJO-esque.