I just joined a project with a lot of existing code.  The following is a 
modified example of a pattern I see a lot:
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
    "things"
})
public class CodeRequest {

    @JsonProperty("things")
    private List<Thing> things = null;
    @JsonIgnore
    private Map<String, Object> additionalProperties = new HashMap<>();

    @JsonProperty("things")
    public List<Thing> getThings() {
        return things;
    }

    @JsonProperty("things")
    public void setThings(List<Thing> things) {
        this.things = things;
    }

I have a problem with how they have redundant @JsonProperty annotations on 
the variable, getter, and setter, but that's a different issue.

In many places where deserialized instances of this are iterated over, 
people often check to see if the list entry is null, to avoid NPEs.

My question is, if Jackson is the only framework creating this instance and 
writing to it, is there any way someone could produce JSON that would 
result in null list entries?  Does the "NON_NULL" reference at the top 
prevent any of that?

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to