Done ticket GEPAFINBE-202
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user