【发布时间】:2021-02-01 22:40:39
【问题描述】:
我有以下 json,我想更新该 json 的每一个值,但有时只有一个值
{
"msgType": "NEW",
"code": "205",
"plid": "PLB52145",
}
我已经尝试使用以下代码进行更新
FileReader reader = new FileReader(filePath);
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);
System.out.println(jsonObject);
long id =Long.valueOf((String) idNewObj.get("plid"));
System.out.println(plid);
idNewObj.put("plid",PL809809809);
System.out.println(jsonObject);
【问题讨论】:
-
输出是什么?有什么问题?
-
value were not changed ,因此给出以下解决方案来写入值。它有效:) 谢谢@papaya