Answer the question
In order to leave comments, you need to log in
Make attributes in JSON required?
Does anyone know an elegant way to make certain attributes in JSON mandatory.
Rather, it is inconsistent with the nature of JSON. Forgive me frontend!
But in practice, config is stored in JSON and you don't want to do a check in every component that uses this mechanism. A is more likely at once at a deserialization.
Yes:
1) Jackson 2.6
@JsonCreator
public MyClass(@JsonProperty(value = "x", required = true) Integer x, @JsonProperty(value = "value_y", required = y) Integer totalCount) {
...
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question