java - Include NULL values in Json Response -


i see json response null fields. if set defalut value null in json schema, fields not getting displayed. think, null fields getting filtered internally. ex.

"streetaddress": {             "line1": "2374 water works rd"             "line2" : null           }, 

currently if don't set line2 , not getting appeared in response. getting

"streetaddress": {             "line1": "2374 water works rd"              } 

pom.xml

pojo's 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 sysout before returning json response , see null fields present.

[line1=2374 water works rd,line2=anglebracketopennullanglebracketclose]

i using swagger , post man rest client. in both null field not appearing.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -