Skip to content

Commit

Permalink
Added new BrowserMob alter method for updating the JSON object instea…
Browse files Browse the repository at this point in the history
…d of using RegeX. Very cool
  • Loading branch information
alombardorccl committed Jun 5, 2023
1 parent 0acf10f commit 54a3066
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,15 @@ public void alterResponse(final String targetUrl, final String replace, final St
} catch (JSONException e) {
LOG(false, "Unable to alter array-based JSON e=%s", e.getMessage());
}

if (!successfulMock) {
try {
JSONObject replacementObject = new JSONObject(replace);
jsonObject.getJSONObject(parentField).put(fieldToReplace, replacementObject);
successfulMock = true;
} catch (JSONException e) {
LOG(false, "Unable to alter object replacement JSON e=%s", e.getMessage());
}
}
if (!successfulMock) {
try {
jsonObject.getJSONObject(parentField).put(fieldToReplace, replace);
Expand Down

0 comments on commit 54a3066

Please sign in to comment.