简体   繁体   中英

Sort serialized object alphabetically (Java)

Say I have the following Json string which is a serialized object:

{"ID":27,"Name":"QA14ADMINOPM201","OSBits":null,"OSName":null, "SupportedLocales": "NA","Global"],"MachineSpec":null,"Proxy":null}

Is there a way for me to alphabetize the string by field so that the string becomes:

{"ID":27,"MachineSpec":null,"Name":"QA14ADMINOPM201","OSBits":null,"OSName":null,"Proxy":null, "SupportedLocales":["NA","Global"]}

And also make it so that if there were another object field within this object, all of this object's fields would also be sorted?

It's been looooooooog time. But jaskson can do it: spring.jackson.mapper.sort-properties-alphabetically=true

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