Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to Restrict unassigned variable to not get from POJO to JSON?

I have a class A, with two variable varOne, varTwo,
While assigning I only assigned varTwo, but when converting to JSON I’m getting both the value
one which was unassigned is as null.
What can I do to restrict varOne. if varOne is unassigned the I don’t want it at all in Json.

I tried reconstruct the JSON. but feels like could do better.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can put @JsonInclude(JsonInclude.Include.NON_NULL) above the class

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading