正如上面的标题所述,我试图将“ name ”的值替换为“ abc ”,但这似乎并没有覆盖它,因为使用简单 Json java 代码替换它后它是相同的值。
这是我的java代码:
String jsonString =
"{"
+ "\"data\":"
+ "["
+ "{"
+ "\"jazz\":\"black\","
+ "\"name\":\"white\","
+ "\"given\":\"red\","
+ "\"sam\":\"blue\","
+ "\"mail\":\"yellow\","
+ "\"member\":\"green\","
+ "\"department\":\"green\","
+ "\"title\":\"green\""
+ "}"
+ "]"
+ "}";
JSONParser parser = new JSONParser();
JSONObject jsonObj = (JSONObject) parser.parse(jsonString);
JSONObject newJSON = new JSONObject();
jsonObj.remove("name");
jsonObj.put("name", "abc");
正如我所说,上面的代码似乎没有对json 结构中已有的“ name ”属性执行任何操作。上面的输出看起来像这样:
{
"data": [
{
"given": "red",
"mail": "yellow",
"jazz": "black",
"name": "white",
"member": "green",
"department": "green",
"title": "green",
"sam": "blue"
}
],
"name": "abc"
}
输出应该是什么样子:
{
"data": [
{
"given": "red",
"mail": "yellow",
"jazz": "black",
"name": "abc",
"member": "green",
"department": "green",
"title": "green",
"sam": "blue"
}
]
}
知道为什么它不改变它吗?
慕沐林林
慕尼黑5688855
白衣染霜花
相关分类