java - 我在输出 JsonFile 中的键以相反的顺序显示
问题描述
我正在使用一种方法来显示包含一些信息和键值的 JsonArray,但是该方法在键之前显示数组,而我想要相反。有人能告诉我我的错误在哪里吗?我的方法是:
@SuppressWarnings("unchecked")
public void ecrireFichierJSon(String fichierSortie) {
org.json.simple.JSONObject completOrNot = new org.json.simple.JSONObject();
if (mssgErreurResult().isEmpty()) {
completOrNot.put("complet", true);
} else {
completOrNot.put("complet", false);
}
org.json.simple.JSONArray messagesErreur = new org.json.simple.JSONArray();
messagesErreur.addAll(mssgErreurResult());
completOrNot.put("erreurs", messagesErreur);
org.json.simple.JSONArray erreurList = new org.json.simple.JSONArray();
erreurList.add(completOrNot);
try {
Files.write(Paths.get(fichierSortie), completOrNot.toJSONString().getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
这是输出文件:
{"erreurs":["Errors..."],"complet":false}
解决方案
推荐阅读
- python - 过滤掉一些不包含python中列的特定情况的组
- reactjs - 如何在 material-ui 5 中正确使用主题、样式全局变量和溢出
- vue.js - 如何观看多个倒数计时器vuejs
- oracle - 使用 sql loader 加载到表中时跳过前两条记录
- angular - 找不到 i18n .json | 角
- javascript - Javascript输入keyup第一个值=“-”不是NaN
- c# - 无法开始收听 ManagementEventWatcher
- python - 根据两列的值添加另一列
- reactjs - 如何配置你为什么用 NextJS 12 渲染
- mysql - mysql查询以查找针对任何类别仅具有单个特定子类别的行(按数据分组)