Class JsonUtil


  • public class JsonUtil
    extends Object
    Json util.
    Since:
    1.0.0
    Author:
    imre.scheffer
    • Method Detail

      • toObjectUncheckedEx

        public static <T> T toObjectUncheckedEx​(String json,
                                                Type typeOfT)
                                         throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Converting JSON string to DTO object
        Type Parameters:
        T - type of returned object
        Parameters:
        json - JSON String
        typeOfT - type of returned object
        Returns:
        object
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - exception
      • toObjectUncheckedGson

        public static <T> T toObjectUncheckedGson​(String json,
                                                  Type typeOfT)
        Convert JSON String to DTO object without throwing exception
        Type Parameters:
        T - type of returned object
        Parameters:
        json - JSON String
        typeOfT - type of returned object
        Returns:
        DTO
      • toObjectUncheckedGson

        public static <T> T toObjectUncheckedGson​(Reader reader,
                                                  Type typeOfT)
        Convert JSON String to DTO object without throwing exception
        Type Parameters:
        T - type of returned object
        Parameters:
        reader - JSON reader
        typeOfT - type of returned object
        Returns:
        DTO
      • toJson

        public static String toJson​(Object dto)
        Converting DTO object to JSON string without throwing exception
        Parameters:
        dto - DTO object
        Returns:
        JSON String
      • toObject

        public static <T> T toObject​(String json,
                                     Class<T> classType)
        Converting JSON string to DTO object without throwing exception
        Type Parameters:
        T - type of returned object
        Parameters:
        json - JSON String
        classType - class of returned object
        Returns:
        object
      • toObjectUnchecked

        public static <T> T toObjectUnchecked​(String json,
                                              Type typeOfT)
        Converting JSON string to DTO object without throwing exception
        Type Parameters:
        T - type of returned object
        Parameters:
        json - JSON String
        typeOfT - type of returned object
        Returns:
        object
      • toJsonEx

        public static String toJsonEx​(Object dto)
                               throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Converting DTO object to JSON string
        Parameters:
        dto - DTO object
        Returns:
        JSON String
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - exception
      • toObjectEx

        public static <T> T toObjectEx​(String json,
                                       Class<T> classType)
                                throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Converting JSON string to DTO object
        Type Parameters:
        T - type of returned object
        Parameters:
        json - JSON String
        classType - class of returned object
        Returns:
        object
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - exception
      • toJsonGson

        public static String toJsonGson​(Object dto)
        Converting DTO object to JSON string
        Parameters:
        dto - DTO object
        Returns:
        JSON String
      • toObjectGson

        public static <T> T toObjectGson​(String json,
                                         Class<T> classType)
        Convert JSON String to DTO object without throwing exception
        Type Parameters:
        T - type of returned object
        Parameters:
        json - JSON String
        classType - class of returned object
        Returns:
        DTO
      • toObjectGson

        public static <T> T toObjectGson​(Reader reader,
                                         Class<T> classType)
        Convert JSON String to DTO object without throwing exception
        Type Parameters:
        T - type of returned object
        Parameters:
        reader - JSON reader
        classType - class of returned object
        Returns:
        DTO