Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix json.path functions adding extra / and \ to json objects #692

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public Object childEvaluate(Parser parser, String functionName, List<Object> par
String jsonStr = parameters.get(0).toString();
String path = parameters.get(1).toString();
Object value = parameters.get(2);
Object json = convertToJSON(value.toString());
if (json != null) value = json; // to prevent quotes getting turned into \" and \"

try {
return JsonPath.parse(jsonStr).add(path, value).jsonString(); // add element to array
Expand All @@ -128,6 +130,8 @@ public Object childEvaluate(Parser parser, String functionName, List<Object> par
String jsonStr = parameters.get(0).toString();
String path = parameters.get(1).toString();
Object value = parameters.get(2);
Object json = convertToJSON(value.toString());
if (json != null) value = json;

try {
return JsonPath.parse(jsonStr).set(path, value).jsonString(); // set element in array/object
Expand All @@ -143,6 +147,8 @@ public Object childEvaluate(Parser parser, String functionName, List<Object> par
String path = parameters.get(1).toString();
String key = parameters.get(2).toString();
Object value = parameters.get(3);
Object json = convertToJSON(value.toString());
if (json != null) value = json;

try {
return JsonPath.parse(jsonStr).put(path, key, value).jsonString(); // add value in object
Expand Down