public class JsonUtils extends Object
org.boon.json library.| Modifier and Type | Method and Description |
|---|---|
static Map<String,Object> |
convertToMap(Object o)
Converts a given Json object to a Json map.
|
static boolean |
getBooleanFrom(Map<String,Object> map,
String key,
boolean required)
Retrieves a Json boolean from the specified Json map given its key.
|
static List<Object> |
getListFrom(Map<String,Object> map,
String key)
Retrieves a Json array from the specified Json map given its key.
|
static Long |
getLongFrom(Map<String,Object> map,
String key,
boolean required)
Retrieves a Json number as a long from the specified Json map given its key.
|
static Map<String,Object> |
getMapFrom(Map<String,Object> map,
String key)
Retrieves a Json map from the specified Json map given its key.
|
static String |
getStringFrom(Map<String,Object> map,
String key,
boolean required)
Retrieves a Json string from the specified Json map given its key.
|
public static Map<String,Object> convertToMap(@Nullable Object o)
o - the Json object to return as a mapMigrationException - if the given object is not a mappublic static Map<String,Object> getMapFrom(@Nullable Map<String,Object> map, @Nullable String key)
map - the map to retrieve an entry fromkey - the key for the entry to retrieveMigrationException - if the specified entry is not a Json mappublic static List<Object> getListFrom(@Nullable Map<String,Object> map, @Nullable String key)
map - the map to retrieve an entry fromkey - the key for the entry to retrieveMigrationException - if the specified entry is not a Json arraypublic static String getStringFrom(@Nullable Map<String,Object> map, @Nullable String key, boolean required)
map - the map to retrieve an entry fromkey - the key for the entry to retrieverequired - true if the entry must exist in the map otherwise an error is
generated; false to return null if it doesn't existnull if it doesn't exist and
required is falseMigrationException - if the specified entry is not a Json string or if it doesn't exist
and required is truepublic static Long getLongFrom(@Nullable Map<String,Object> map, @Nullable String key, boolean required)
map - the map to retrieve an entry fromkey - the key for the entry to retrieverequired - true if the entry must exist in the map otherwise an error is
generated; false to return null if it doesn't existnull if it doesn't exist and
required is falseMigrationException - if the specified entry is not a Json number or if it doesn't exist
and required is truepublic static boolean getBooleanFrom(@Nullable Map<String,Object> map, @Nullable String key, boolean required)
map - the map to retrieve an entry fromkey - the key for the entry to retrieverequired - true if the entry must exist in the map otherwise an error is
generated; false to return null if it doesn't existfalse if it doesn't exist and
required is falseMigrationException - if the specified entry is not a Json boolean or if it doesn't exist
and required is trueThis work is licensed under a Creative Commons Attribution 4.0 International License.