当前位置:网站首页>Jsonobject data guarantee order of fastjson
Jsonobject data guarantee order of fastjson
2022-04-22 18:42:00 【susu1083018911】
In the use of fastjson Of JSONObject Of put After the data , The sort will change , for example :
public static void main(String[] args) throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("b", "2222");
jsonObject.put("a", "1111");
jsonObject.put("d", "4444");
jsonObject.put("c", "3333");
String jsonString = jsonObject.toJSONString();
System.out.println(jsonObject);
}

because JsonObject The default null parameter construction method is HashMap To store the , So the output is by key From the order of , If you want to make JsonObject In a fixed order (put The order of ) array , You can modify JsonObject The definition of HashMap Change it to LinkedHashMap
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());

版权声明
本文为[susu1083018911]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221837199027.html
边栏推荐
猜你喜欢
![Convolution of images -- [torch learning notes]](/img/7f/4e608cf391dbbfa7973a1a0c066c6c.png)
Convolution of images -- [torch learning notes]

fastjson的JSONObject数据保证顺序

花样机模板电脑CAD免费打板转格式软件PS300B使用步骤教程:日本兄弟牌Brother花样机通用CAD画图打板.dxf文件转.emb文件

Golang gin websocket problem

不产桩不建桩,充电服务商NaaS靠什么崛起?

Alipay open platform application - Township Health Center Application

2022 mise à niveau du concours de langues et de technologies intelligentes pour lancer les quatre tâches de pointe du PNL

Win10问题篇:一次性永久关闭win10系统自动更新

聊聊我这些年错过的一些机遇

关于.net core 中使用ActionFilter 以及ActionFilter的自动事务
随机推荐
大话测试数据(一)
图像的卷积——【torch学习笔记】
[drive] TX2 transplants EC20 startup module
2022 mise à niveau du concours de langues et de technologies intelligentes pour lancer les quatre tâches de pointe du PNL
【接口测试基础】第九篇 | 详解PostMan全局变量和环境变量
【bat】查看文件md5
数据分析师职业规划——数据分析师的职业焦虑与未来发展
模块代码的类型描述文件
【接口测试基础】第八篇 | PostMan常用断言及断言的工作原理
带你了解极具弹性的Spark架构的原理
HackMyvm(二十五)Helium,系列文章持续更新
nodejs如何预防xss攻击
leetcode - 234. 回文链表
Kellerman Software .NET SFTP Library
.net core 中集成Identity框架
【CIcadplayer】进度条回调
目前国产电脑硬件的现状是怎样的?
PCB Layout Stackup setting
Talk about the pit of cache Boolean value
WiFi技术概述:WiFi那些事