Done ticket GEPAFINBE-202

This commit is contained in:
piyushkag
2025-04-17 12:27:38 +05:30
parent af622208ed
commit 809c89deed
15 changed files with 730 additions and 18 deletions

View File

@@ -986,5 +986,30 @@ public class Utils {
}
}
}
public static List<Map<String, Object>> convertJsonToListMap(String jsonString) {
try {
if (jsonString == null || jsonString.trim().isEmpty()) {
return Collections.emptyList();
}
ObjectMapper objectMapper = new ObjectMapper();
String unescaped;
// First try: parse as if it's double-encoded (escaped string containing a JSON array)
try {
unescaped = objectMapper.readValue(jsonString, String.class);
} catch (Exception e) {
// If that fails, assume it's already a proper JSON array
unescaped = jsonString;
}
// Now parse the actual JSON array
return objectMapper.readValue(unescaped, new TypeReference<List<Map<String, Object>>>() {});
} catch (Exception e) {
e.printStackTrace();
return Collections.emptyList();
}
}
}