Код: Выделить всё
ObjectMapper mapper = new ObjectMapper()
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
Map map = ImmutableMap.of(
"c", "3",
"b", "2",
"a", "1");
System.out.println("1) " + mapper.writeValueAsString(map));
JsonNode jsonNode = mapper.createObjectNode()
.put("c", "3")
.put("b", "2")
.put("a", "1");
System.out.println("2) " + mapper.writeValueAsString(jsonNode));
Код: Выделить всё
1) {"a":"1","b":"2","c":"3"}
2) {"c":"3","b":"2","a":"1"}
Подробнее здесь: https://stackoverflow.com/questions/794 ... ization-fe