'jsoniter how to prevent print null to json
I use Jsoniter to deserialize jsons and serialize objects to json. I have an object with many properties and add them as json member by @JsonProperty("xxx"). when use the following code for print json message of an object:
JsonStream.serialize(this);
I see members with null value in output. required:
{"title":"Clean Code","price":42}
but I see:
{"title":"Clean Code","author":null,"price":42}
How to prevent printing null members (author in this example) in Jsoniter? (something like @JsonInclude(Include.NON_NULL) in Jackson)
Solution 1:[1]
It looks like this requirement is an open issue
Workaround: According to the provided link you should use JsonProperty like
@JsonProperty(defaultValueToOmit = "null") to ignore the null fields.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
