简体   繁体   中英

Object to Json including only fields not null

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM