I have an object named Item with plenty of fields. I'm using a Java JSON (json-io) library to serialize its state in a File:
String json = JsonWriter.objectToJson(item);
// Write String to File
I'd like to make the json String less verbose so that it does not include null values (if possible also boolean which are false). Is it possible to do it somehow ?
Thanks
I can recommend using jackson mapper if possible. Check out these two questions:
Jackson serialization: ignore empty values (or null)
How to tell Jackson to ignore a field during serialization if its value is null?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With