Skip to content

Commit

Permalink
Fix json path issue in Enrich Mediator
Browse files Browse the repository at this point in the history
Fix issue with Enrich mediator after Json Path Upgrade
Fix wso2/product-micro-integrator#3116
  • Loading branch information
dulanjalidilmi committed Feb 14, 2024
1 parent 564af81 commit b14a208
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,15 @@ private String removeJSONFromString(MessageContext synCtx, String inputString, S
if (path.equals("$") || path.equals("$.")) {
result = "";
} else {
DocumentContext doc = JsonPath.parse(result);
doc.delete(path);
result = doc.jsonString();
Object list = JsonPath.compile(path).read(result);
if (!((JsonArray) list).isEmpty()) {
DocumentContext doc = JsonPath.parse(result);
doc.delete(path);
result = doc.jsonString();
} else {
log.warn("No matching elements were found for the given JSONPath: " + path + ". Therefore, " +
"no elements were removed.");
}
}
}
}
Expand Down

0 comments on commit b14a208

Please sign in to comment.