Browse Source

changes in json validation service class

master
yoganandhank 1 year ago
parent
commit
957709a862
  1. 12
      src/main/java/com/gcc/crslogs/service/BirthAndDeathDetailsService.java

12
src/main/java/com/gcc/crslogs/service/BirthAndDeathDetailsService.java

@ -1,7 +1,8 @@
package com.gcc.crslogs.service;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@ -15,7 +16,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -76,7 +77,7 @@ public class BirthAndDeathDetailsService {
}
@ -125,7 +126,10 @@ public class BirthAndDeathDetailsService {
.replaceAll("\t", "") // Remove tab characters explicitly (common cause of error)
.replaceAll("\\s*:\\s*\n\\s*\"", ":\"") // Fix broken key-value splits
.replaceAll("\r", "") // Remove carriage return if any
.replaceAll("\n", ""); // Optionally remove newlines if JSON is malformed across lines
.replaceAll("\n", "") // Optionally remove newlines if JSON is malformed across lines
.replaceAll(",\\s*\\[", "[") // Remove comma before array start
.replaceAll("\\[\\s*,", "[") // Remove comma after array start
.replaceAll(",\\s*\\]", "]"); // Remove trailing comma in array
}

Loading…
Cancel
Save