且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更改json对象名称(键)?

更新时间:2023-01-17 07:37:20

正确而紧凑的实现,假设 jsonObject 是您引用的json对象,它是 JSONObject 的实例:

Proper and compact implementation, given that jsonObject is the json object you are referring to and it is an instance of JSONObject:

jsonObject.put("new name", jsonObject.remove("name"));