Class JsonUtil


  • public final class JsonUtil
    extends Object
    Author:
    Tassilo Weidner
    • Field Detail

      • gsonMapper

        protected static com.google.gson.Gson gsonMapper
    • Constructor Detail

      • JsonUtil

        public JsonUtil()
    • Method Detail

      • addFieldRawValue

        public static void addFieldRawValue​(com.google.gson.JsonObject jsonObject,
                                            String memberName,
                                            Object rawValue)
      • addField

        public static <T> void addField​(com.google.gson.JsonObject jsonObject,
                                        String name,
                                        JsonObjectConverter<T> converter,
                                        T value)
      • addListField

        public static void addListField​(com.google.gson.JsonObject jsonObject,
                                        String name,
                                        List<String> list)
      • addArrayField

        public static void addArrayField​(com.google.gson.JsonObject jsonObject,
                                         String name,
                                         String[] array)
      • addDateField

        public static void addDateField​(com.google.gson.JsonObject jsonObject,
                                        String name,
                                        Date date)
      • addElement

        public static <T> void addElement​(com.google.gson.JsonArray jsonObject,
                                          JsonObjectConverter<T> converter,
                                          T value)
      • addListField

        public static <T> void addListField​(com.google.gson.JsonObject jsonObject,
                                            String name,
                                            JsonObjectConverter<T> converter,
                                            List<T> list)
      • asJavaObject

        public static <T> T asJavaObject​(com.google.gson.JsonObject jsonObject,
                                         JsonObjectConverter<T> converter)
      • addNullField

        public static void addNullField​(com.google.gson.JsonObject jsonObject,
                                        String name)
      • addField

        public static void addField​(com.google.gson.JsonObject jsonObject,
                                    String name,
                                    com.google.gson.JsonArray value)
      • addField

        public static void addField​(com.google.gson.JsonObject jsonObject,
                                    String name,
                                    String value)
      • addField

        public static void addField​(com.google.gson.JsonObject jsonObject,
                                    String name,
                                    Boolean value)
      • addField

        public static void addField​(com.google.gson.JsonObject jsonObject,
                                    String name,
                                    Integer value)
      • addField

        public static void addField​(com.google.gson.JsonObject jsonObject,
                                    String name,
                                    Short value)
      • addField

        public static void addField​(com.google.gson.JsonObject jsonObject,
                                    String name,
                                    Long value)
      • addField

        public static void addField​(com.google.gson.JsonObject jsonObject,
                                    String name,
                                    Double value)
      • addDefaultField

        public static void addDefaultField​(com.google.gson.JsonObject jsonObject,
                                           String name,
                                           boolean defaultValue,
                                           Boolean value)
      • asBytes

        public static byte[] asBytes​(com.google.gson.JsonElement jsonObject)
      • asObject

        public static com.google.gson.JsonObject asObject​(byte[] byteArray)
      • asObject

        public static com.google.gson.JsonObject asObject​(String jsonString)
      • asObject

        public static com.google.gson.JsonObject asObject​(Map<String,​Object> properties)
      • asStringList

        public static List<String> asStringList​(com.google.gson.JsonElement jsonObject)
      • asList

        public static <T,​S extends List<T>> S asList​(com.google.gson.JsonArray jsonArray,
                                                           JsonObjectConverter<T> converter,
                                                           Supplier<S> listSupplier)
      • asList

        public static <T> List<T> asList​(com.google.gson.JsonArray jsonArray,
                                         JsonObjectConverter<T> converter)
      • asList

        public static List<Object> asList​(com.google.gson.JsonElement jsonElement)
      • asMap

        public static Map<String,​Object> asMap​(com.google.gson.JsonElement jsonElement)
      • asArray

        public static com.google.gson.JsonArray asArray​(List<String> list)
      • getRawObject

        public static Object getRawObject​(com.google.gson.JsonObject jsonObject,
                                          String memberName)
      • asPrimitiveObject

        public static Object asPrimitiveObject​(com.google.gson.JsonPrimitive jsonValue)
      • parseNumber

        protected static Number parseNumber​(String numberString)
      • getBoolean

        public static boolean getBoolean​(com.google.gson.JsonObject json,
                                         String memberName)
      • getString

        public static String getString​(com.google.gson.JsonObject json,
                                       String memberName)
      • getString

        public static String getString​(com.google.gson.JsonObject json,
                                       String memberName,
                                       String defaultString)
      • getString

        public static String getString​(com.google.gson.JsonElement jsonElement)
      • getInt

        public static int getInt​(com.google.gson.JsonObject json,
                                 String memberName)
      • isNull

        public static boolean isNull​(com.google.gson.JsonObject jsonObject,
                                     String memberName)
      • getLong

        public static long getLong​(com.google.gson.JsonObject json,
                                   String memberName)
      • getArray

        public static com.google.gson.JsonArray getArray​(com.google.gson.JsonObject json,
                                                         String memberName)
      • getArray

        public static com.google.gson.JsonArray getArray​(com.google.gson.JsonElement json)
      • getObject

        public static com.google.gson.JsonObject getObject​(com.google.gson.JsonObject json,
                                                           String memberName)
      • getObject

        public static com.google.gson.JsonObject getObject​(com.google.gson.JsonElement json)
      • createObject

        public static com.google.gson.JsonObject createObject()
      • createArray

        public static com.google.gson.JsonArray createArray()
      • getGsonMapper

        public static com.google.gson.Gson getGsonMapper()
      • createGsonMapper

        public static com.google.gson.Gson createGsonMapper()