Changes in application evaluation

This commit is contained in:
rajesh
2024-12-19 17:02:23 +05:30
parent 54f26f5200
commit 9c0acfb831
6 changed files with 228 additions and 156 deletions

View File

@@ -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;
}
}
}