简体   繁体   English

按字母顺序对序列化对象进行排序(Java)

[英]Sort serialized object alphabetically (Java)

Say I have the following Json string which is a serialized object: 说我有以下Json字符串,它是一个序列化的对象:

{"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 但是jaskson可以做到:spring.jackson.mapper.sort-properties-alphabetically = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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