【发布时间】:2020-02-12 06:50:56
【问题描述】:
我有一个这样的 json:
{
"application": "ERP",
"subject": "Quote 0000005 from TestSG",
"exportDocumentRequest": {
"documentDate": "05-02-2020",
"tenantBillingAddr": null,
"code": "0000"
}
}
我需要将“code”值(即“0000”)替换为“1234” 我尝试通过引用此Building a nested JSONObject
来关注JSONObject requestParams = Utilities.readJSON("MyFile.json");
JSONObject childJSON = new JSONObject();
childJSON.put("code", "1234");
requestParams.put("exportDocumentRequest", childJSON);
但它给了我这样的输出:
{
"application": "ERP",
"subject": "Quote 0000005 from TestSG",
"exportDocumentRequest": {
"code": "0000"
}
}
它正在删除“exportDocumentRequest”中的其他子字段。我需要它像这样更新“代码”:
{
"application": "ERP",
"subject": "Quote 0000005 from TestSG",
"exportDocumentRequest": {
"documentDate": "05-02-2020",
"tenantBillingAddr": null,
"code": "1234"
}
}
【问题讨论】:
标签: java json rest-assured-jsonpath