I would like to see the json response with null fields. Even if set the defalut value as null in the json schema, those fields are not getting displayed. I think, all null fields are getting filtered internally. for ex.
"streetAddress": {
"line1": "2374 WATER WORKS RD"
"line2" : null
},
Currently if i don't set the line2 , it is not getting appeared in the response. Simply i am getting
"streetAddress": {
"line1": "2374 WATER WORKS RD"
}
pom.xml
POJO's are generated using maven plugin
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>0.4.11</version>
<configuration>
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
<targetPackage>com.dnb.daas.matchplus.product.ng.schema.request</targetPackage>
<includeJsr303Annotations>true</includeJsr303Annotations>
<initializeCollections>false</initializeCollections>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Json Schema:
"streetAddress": {
"id": "streetAddress",
"type": "object",
"properties": {
"line1": {
"id": "line1",
"type": "string"
},
"line2": {
"id": "line2",
"type": "string"
}
},
"additionalProperties": false
}
Sample POJO:
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"line1",
"line2"
})
public class StreetAddress {
@JsonProperty("line1")
private String line1;
@JsonProperty("line2")
private String line2;
I tried putting a sysout before returning the json response and i could see the null fields are present.
[line1=2374 WATER WORKS RD,line2=AnglebracketOpennullAngleBracketClose]
I am using Swagger and Post Man as the rest client. In both null field are not appearing.
@JsonInclude(JsonInclude.Include.NON_NULL)?