Skip to content

Commit a541fa8

Browse files
committed
Use string.replace when trying to correct poorly escaped json
1 parent 5b9a5bd commit a541fa8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/java/com/mongodb/kafka/connect/util/ConfigHelper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static Optional<Document> documentFromString(
5959
throw originalError;
6060
} else {
6161
return documentFromString(
62-
jsonDocument.replaceAll("\\\\", "\\\\\\\\"),
62+
jsonDocument.replace("\\", "\\\\"),
6363
new ConfigException("Not a valid JSON document", e));
6464
}
6565
}
@@ -80,8 +80,7 @@ private static Optional<List<Document>> jsonArrayFromString(
8080
throw originalError;
8181
} else {
8282
return jsonArrayFromString(
83-
jsonArray.replaceAll("\\\\", "\\\\\\\\"),
84-
new ConfigException("Not a valid JSON array", e));
83+
jsonArray.replace("\\", "\\\\"), new ConfigException("Not a valid JSON array", e));
8584
}
8685
}
8786
}

0 commit comments

Comments
 (0)