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

Apply compat fix for json.path.set and json.path.delete as well #4317

Merged
merged 1 commit into from
Oct 16, 2023
Merged
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 @@ -872,7 +872,12 @@ private JsonElement shallowCopy(JsonElement jsonElement) {
* @return The resulting json data.
*/
private JsonElement jsonPathDelete(JsonElement json, String path) {
return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).delete(path).json();
try {
return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).delete(path).json();
} catch (PathNotFoundException ex) {
// Return original json, this is to preserve backwards compatability pre library update
return json;
}
}

/**
Expand Down Expand Up @@ -906,7 +911,12 @@ private JsonElement jsonPathPut(JsonElement json, String path, String key, Objec
private JsonElement jsonPathSet(JsonElement json, String path, Object info) {
Object value = asJsonElement(info);

return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).set(path, value).json();
try {
return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).set(path, value).json();
} catch (PathNotFoundException ex) {
// Return original json, this is to preserve backwards compatability pre library update
return json;
}
}

/**
Expand Down
Loading