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 dbc4bef commit 573b1da
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 found for the given JSONPath: " + path + ". Hence no elements " +
"removed.");
}
}
}
}
Expand Down

0 comments on commit 573b1da

Please sign in to comment.