JSON 格式化输出并按“键”排序
作者:
一飞冲不了天 | 来源:发表于
2024-02-05 11:37 被阅读0次import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import net.minidev.json.parser.JSONParser;
String json = ".......json string.........."
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
Object o = new JSONParser(JSONParser.DEFAULT_PERMISSIVE_MODE).parse(json);
System.out.println(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(o));
本文标题:JSON 格式化输出并按“键”排序
本文链接:https://www.haomeiwen.com/subject/bgsqadtx.html
网友评论