|
|
|
@ -141,10 +141,37 @@ public class BirthAndDeathDetailsService { |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// private String sanitizeJsonResponse(String rawJson) { |
|
|
|
// if (rawJson == null) return ""; |
|
|
|
|
|
|
|
// return rawJson |
|
|
|
// .replace("\\", "\\\\") // Escape backslashes |
|
|
|
// .replaceAll("[\\p{Cntrl}&&[^\r\n\t]]", "") // Remove non-printable control characters |
|
|
|
// .replaceAll("\t", "") // Remove tab characters |
|
|
|
// .replaceAll("\\s*:\\s*\n\\s*\"", ":\"") // Fix broken key-value splits |
|
|
|
// .replaceAll("\r", "") // Remove carriage return |
|
|
|
// .replaceAll("\n", "") // Remove newlines |
|
|
|
// .replaceAll(",\\s*\\[", "[") // Remove comma before array start |
|
|
|
// .replaceAll("\\[\\s*,", "[") // Remove comma after array start |
|
|
|
// .replaceAll(",\\s*\\]", "]") // Remove trailing comma in array |
|
|
|
// .replaceAll("\"\"\"", "\"\"") // ← fix triple quotes |
|
|
|
// .replaceAll("\"{3,}", "\"") // ← fallback: collapse 3+ quotes to 1 |
|
|
|
// .replaceAll(":(\\s*)\"{2,}\"", ":\"\"") // ← handle `:"""` to `:""` |
|
|
|
// .replaceAll("\"\\s*\\(", " ("); // Remove quote before parenthesis |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
private String sanitizeJsonResponse(String rawJson) { |
|
|
|
if (rawJson == null) return ""; |
|
|
|
|
|
|
|
return rawJson |
|
|
|
// Remove quote before parenthesis (fixes: "NAME" : "ABC "(LATE)") |
|
|
|
String fixed = rawJson.replaceAll("\"\\s*\\(([^)]*)\\)\"", " ($1)\""); |
|
|
|
|
|
|
|
// Remove parenthesis and content outside of quotes (fixes: ... "ABC" (LATE) ... → ... "ABC" ...) |
|
|
|
fixed = fixed.replaceAll("\"\\s*\\([^)]*\\)", "\""); |
|
|
|
|
|
|
|
return fixed |
|
|
|
.replace("\\", "\\\\") // Escape backslashes |
|
|
|
.replaceAll("[\\p{Cntrl}&&[^\r\n\t]]", "") // Remove non-printable control characters |
|
|
|
.replaceAll("\t", "") // Remove tab characters |
|
|
|
@ -154,12 +181,10 @@ public class BirthAndDeathDetailsService { |
|
|
|
.replaceAll(",\\s*\\[", "[") // Remove comma before array start |
|
|
|
.replaceAll("\\[\\s*,", "[") // Remove comma after array start |
|
|
|
.replaceAll(",\\s*\\]", "]") // Remove trailing comma in array |
|
|
|
.replaceAll("\"\"\"", "\"\"") // ← fix triple quotes |
|
|
|
.replaceAll("\"{3,}", "\"") // ← fallback: collapse 3+ quotes to 1 |
|
|
|
.replaceAll(":(\\s*)\"{2,}\"", ":\"\""); // ← handle `:"""` to `:""` |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.replaceAll("\"\"\"", "\"\"") // fix triple quotes |
|
|
|
.replaceAll("\"{3,}", "\"") // collapse 3+ quotes to 1 |
|
|
|
.replaceAll(":(\\s*)\"{2,}\"", ":\"\""); // handle `:"""` to `:""` |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|