Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into develop
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.gepafin.tendermanagement.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -316,6 +317,23 @@ public class Utils {
|
||||
|
||||
return new StringTokenizer(header, ",").nextToken().trim();
|
||||
}
|
||||
public static <T> List<T> convertJsonToList(String json, TypeReference<List<T>> typeRef) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
return objectMapper.readValue(json, typeRef);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public static String convertObjectToJson(Object obj) {
|
||||
try {
|
||||
if(obj == null){return null;}
|
||||
return new ObjectMapper().writeValueAsString(obj);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Failed to convert object to JSON: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("Failed to convert object to JSON", e);}}
|
||||
|
||||
public static String replaceSpacesWithUnderscores(String content) {
|
||||
if (content == null) {
|
||||
|
||||
Reference in New Issue
Block a user