java.lang.Object
callofproject.dev.service.notification.util.JsonUtil

public class JsonUtil extends Object
Utility class for converting objects to JSON strings and vice versa.
  • Method Details

    • convertObjectToJsonString

      public static String convertObjectToJsonString(Object object) throws IOException
      Converts an object to a JSON string.
      Parameters:
      object - the object to be converted
      Returns:
      the JSON string
      Throws:
      IOException - if the object cannot be converted to a JSON string
    • deserializeJson

      public static <T> T deserializeJson(String json, Class<T> clazz) throws IOException
      Converts a JSON string to an object.
      Type Parameters:
      T - the type of the object to be converted
      Parameters:
      json - the JSON string to be converted
      clazz - the class of the object to be converted
      Returns:
      the object
      Throws:
      IOException - if the JSON string cannot be converted to an object