Class JsonUtil
java.lang.Object
org.cibseven.bpm.engine.impl.util.JsonUtil
- Author:
- Tassilo Weidner
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static com.google.gson.Gsonstatic final intThe maximum nesting depth of JSON that the engine reads with Gson, the same as for JSON request bodies of the REST API. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddArrayField(com.google.gson.JsonObject jsonObject, String name, String[] array) static voidaddDateField(com.google.gson.JsonObject jsonObject, String name, Date date) static voidaddDefaultField(com.google.gson.JsonObject jsonObject, String name, boolean defaultValue, Boolean value) static <T> voidaddElement(com.google.gson.JsonArray jsonObject, JsonObjectConverter<T> converter, T value) static voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic <T> voidaddField(com.google.gson.JsonObject jsonObject, String name, JsonObjectConverter<T> converter, T value) static voidaddFieldRawValue(com.google.gson.JsonObject jsonObject, String memberName, Object rawValue) static voidaddListField(com.google.gson.JsonObject jsonObject, String name, List<String> list) static <T> voidaddListField(com.google.gson.JsonObject jsonObject, String name, JsonObjectConverter<T> converter, List<T> list) static voidaddNullField(com.google.gson.JsonObject jsonObject, String name) static com.google.gson.JsonArraystatic byte[]asBytes(com.google.gson.JsonElement jsonObject) static <T> TasJavaObject(com.google.gson.JsonObject jsonObject, JsonObjectConverter<T> converter) static <T> List<T>asList(com.google.gson.JsonArray jsonArray, JsonObjectConverter<T> converter) static <T,S extends List<T>>
SasList(com.google.gson.JsonArray jsonArray, JsonObjectConverter<T> converter, Supplier<S> listSupplier) asList(com.google.gson.JsonElement jsonElement) asMap(com.google.gson.JsonElement jsonElement) static com.google.gson.JsonObjectasObject(byte[] byteArray) static com.google.gson.JsonObjectstatic com.google.gson.JsonObjectstatic ObjectasPrimitiveObject(com.google.gson.JsonPrimitive jsonValue) static Stringstatic StringasStringList(com.google.gson.JsonElement jsonObject) static com.google.gson.JsonArraystatic com.google.gson.Gsonstatic com.google.gson.JsonObjectstatic <T> TReads JSON likeGson.fromJson(String, Class)(lenient, the whole input must be consumed,nullfornullor empty input), but accepts JSON nested up toMAX_JSON_NESTING_DEPTHlevels instead of Gson's default of 255.static <T> TReads JSON likeGson.fromJson(String, Class)with the engine's Gson mapper.static com.google.gson.JsonArraygetArray(com.google.gson.JsonElement json) static com.google.gson.JsonArraystatic booleangetBoolean(com.google.gson.JsonObject json, String memberName) static com.google.gson.Gsonstatic intstatic longstatic com.google.gson.JsonObjectgetObject(com.google.gson.JsonElement json) static com.google.gson.JsonObjectstatic ObjectgetRawObject(com.google.gson.JsonObject jsonObject, String memberName) static StringgetString(com.google.gson.JsonElement jsonElement) static Stringstatic Stringprotected static booleanstatic booleanprotected static voidlogJsonParseException(com.google.gson.JsonParseException e) protected static NumberparseNumber(String numberString)
-
Field Details
-
MAX_JSON_NESTING_DEPTH
public static final int MAX_JSON_NESTING_DEPTHThe maximum nesting depth of JSON that the engine reads with Gson, the same as for JSON request bodies of the REST API. Gson's own default (since Gson 2.12) is 255 (CIB7-2634).- See Also:
-
gsonMapper
protected static com.google.gson.Gson gsonMapper
-
-
Constructor Details
-
JsonUtil
public JsonUtil()
-
-
Method Details
-
addFieldRawValue
-
addField
public static <T> void addField(com.google.gson.JsonObject jsonObject, String name, JsonObjectConverter<T> converter, T value) -
addListField
-
addArrayField
-
addDateField
-
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
-
addField
public static void addField(com.google.gson.JsonObject jsonObject, String name, com.google.gson.JsonArray value) -
addField
-
addField
-
addField
-
addField
-
addField
-
addField
-
addDefaultField
-
asBytes
public static byte[] asBytes(com.google.gson.JsonElement jsonObject) -
asObject
public static com.google.gson.JsonObject asObject(byte[] byteArray) -
asObject
-
asObject
-
asStringList
-
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
-
asMap
-
asString
-
asString
-
asArray
-
getRawObject
-
asPrimitiveObject
-
parseNumber
-
getBoolean
-
getString
-
getString
-
getString
-
getInt
-
isNull
-
getLong
-
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() -
fromJson
Reads JSON likeGson.fromJson(String, Class)with the engine's Gson mapper.- See Also:
-
fromJson
Reads JSON likeGson.fromJson(String, Class)(lenient, the whole input must be consumed,nullfornullor empty input), but accepts JSON nested up toMAX_JSON_NESTING_DEPTHlevels instead of Gson's default of 255.- Throws:
com.google.gson.JsonSyntaxException- if the JSON is malformed or nested deeper thanMAX_JSON_NESTING_DEPTHlevels
-
logJsonParseException
protected static void logJsonParseException(com.google.gson.JsonParseException e) -
isNestingLimitExceeded
-
createGsonMapper
public static com.google.gson.Gson createGsonMapper()
-