Can you please help how replace Json value with another Json.
{
"AppId": "1234",
"Name": null,
"Number": 9878,
"RequestBody": "123",
"Date": null
}
I want to replace RequestBody with other Json
{
"Test": null,
"Value": 9878,
"Date": null
}
Expecting output:
{
"AppId": "1234",
"Name": null,
"Number": 9878,
"RequestBody": "{"Test": null,"Value": 9878,"Date": null}",
"Date": null
}
I tried with below
lr_eval_json("Buffer={ResponseBody}", "JsonObject=MJO",LAST);
lr_json_stringify("JsonObject=MJO","Format=compact", "OutputParam=response",LAST);
lr_save_string(lr_eval_string(lr_eval_string("{response}")),"tmp");
lr_eval_json("Buffer/File=payload.json",
"JsonObject=json_obj", LAST);
lr_json_set_values("JsonObject=json_obj",
"Value={tmp}",
"QueryString=$.RequestBody",
"SelectAll=Yes",
LAST);
lr_json_stringify("JsonObject=json_obj","Format=compact", "OutputParam=newJsonBody",LAST);
lr_save_string(lr_eval_string(lr_eval_string("{newJsonBody}")),"body");
I am getting
{
"AppId": "1234",
"Name": null,
"Number": 9878,
"RequestBody": {"Test": null,"Value": 9878,"Date": null},
"Date": null
}
Issue: Double quotes are missing at RequestBody value. If I place manually It is not taking as Json