Json解析数据导致顺序改变问题

json解析的时候,通常顺序会发生改变,如果我们有保持原有顺序的需求的话可以通过如下方式

1、使用fastJson的Feature.OrderedField

JSONObject respJson = JSONObject.parseObject(jsonStr, Feature.OrderedField);

2、初始化JSONObject的时候

JSONObject(boolean ordered);

3、可以使用Google的Gson,使用gson解析的话是怎么传就是什么顺序

JsonObject jsonObject = new JsonParser().parse(jsonStr).getAsJsonObject();
原文地址:https://www.cnblogs.com/xhy-shine/p/10640967.html