Changes in application evaluation
This commit is contained in:
@@ -669,4 +669,26 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Method to convert a JSON string to an object of type T
|
||||
public static <T> T convertStringToObject(String jsonString, Class<T> clazz) {
|
||||
try {
|
||||
return mapper.readValue(jsonString, clazz);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Handle the exception appropriately (e.g., throw a custom exception)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Method to convert an object of type T to a JSON string
|
||||
public static <T> String convertObjectToString(T object) {
|
||||
try {
|
||||
return mapper.writeValueAsString(object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Handle the exception appropriately (e.g., throw a custom exception)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user