Class AbstractJsonUtilImpl

java.lang.Object
org.apache.dubbo.common.json.impl.AbstractJsonUtilImpl
All Implemented Interfaces:
JsonUtil
Direct Known Subclasses:
FastJson2Impl, FastJsonImpl, GsonImpl, JacksonImpl

public abstract class AbstractJsonUtilImpl extends Object implements JsonUtil
  • Constructor Details

    • AbstractJsonUtilImpl

      public AbstractJsonUtilImpl()
  • Method Details

    • isSupport

      public boolean isSupport()
      Specified by:
      isSupport in interface JsonUtil
    • getList

      public List<?> getList(Map<String,?> obj, String key)
      Specified by:
      getList in interface JsonUtil
    • getListOfObjects

      public List<Map<String,?>> getListOfObjects(Map<String,?> obj, String key)
      Gets a list from an object for the given key, and verifies all entries are objects. If the key is not present, this returns null. If the value is not a List or an entry is not an object, throws an exception.
      Specified by:
      getListOfObjects in interface JsonUtil
    • getListOfStrings

      public List<String> getListOfStrings(Map<String,?> obj, String key)
      Gets a list from an object for the given key, and verifies all entries are strings. If the key is not present, this returns null. If the value is not a List or an entry is not a string, throws an exception.
      Specified by:
      getListOfStrings in interface JsonUtil
    • getObject

      public Map<String,?> getObject(Map<String,?> obj, String key)
      Gets an object from an object for the given key. If the key is not present, this returns null. If the value is not a Map, throws an exception.
      Specified by:
      getObject in interface JsonUtil
    • getNumberAsDouble

      public Double getNumberAsDouble(Map<String,?> obj, String key)
      Gets a number from an object for the given key. If the key is not present, this returns null. If the value does not represent a double, throws an exception.
      Specified by:
      getNumberAsDouble in interface JsonUtil
    • getNumberAsInteger

      public Integer getNumberAsInteger(Map<String,?> obj, String key)
      Gets a number from an object for the given key, casted to an integer. If the key is not present, this returns null. If the value does not represent an integer, throws an exception.
      Specified by:
      getNumberAsInteger in interface JsonUtil
    • getNumberAsLong

      public Long getNumberAsLong(Map<String,?> obj, String key)
      Gets a number from an object for the given key, casted to an long. If the key is not present, this returns null. If the value does not represent a long integer, throws an exception.
      Specified by:
      getNumberAsLong in interface JsonUtil
    • getString

      public String getString(Map<String,?> obj, String key)
      Gets a string from an object for the given key. If the key is not present, this returns null. If the value is not a String, throws an exception.
      Specified by:
      getString in interface JsonUtil
    • checkObjectList

      public List<Map<String,?>> checkObjectList(List<?> rawList)
      Casts a list of unchecked JSON values to a list of checked objects in Java type. If the given list contains a value that is not a Map, throws an exception.
      Specified by:
      checkObjectList in interface JsonUtil
    • checkStringList

      public List<String> checkStringList(List<?> rawList)
      Casts a list of unchecked JSON values to a list of String. If the given list contains a value that is not a String, throws an exception.
      Specified by:
      checkStringList in interface JsonUtil