Package org.spincast.core.json
Class JsonPathUtilsDefault
java.lang.Object
org.spincast.core.json.JsonPathUtilsDefault
- All Implemented Interfaces:
JsonPathUtils
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static enum
-
Constructor Summary
ConstructorDescriptionJsonPathUtilsDefault
(SpincastConfig spincastConfig, JsonManager jsonManager) Constructor -
Method Summary
Modifier and TypeMethodDescriptiongetElementAtJsonPath
(JsonArray array, String jsonPath) Gets an element from theJsonArray
, at the specifiedJsonPath
.getElementAtJsonPath
(JsonArray array, String jsonPath, Object defaultElement) Gets an element from theJsonArray
, at the specifiedJsonPath
.getElementAtJsonPath
(JsonObject obj, String jsonPath) Gets an element from theJsonObject
, at the specifiedJsonPath
.getElementAtJsonPath
(JsonObject obj, String jsonPath, Object defaultElement) Gets an element from theJsonObject
, at the specifiedJsonPath
.protected JsonManager
protected int
protected int
protected SpincastConfig
boolean
isElementExists
(JsonArray array, String jsonPath) Does the array contain an element at theJsonPath
position (even ifnull
)?boolean
isElementExists
(JsonObject root, String jsonPath) Does the object contain an element at theJsonPath
position (even ifnull
)?protected Object
processJsonPath
(JsonObject root, String jsonPath, JsonPathUtilsDefault.JsonPathProcessingType jsonPathProcessingType, Object valueToPut, boolean hasDefaultValue, Object defaultElement) void
putElementAtJsonPath
(JsonObjectOrArray root, String jsonPath, Object valueToAdd) Puts an element in the object at the specifiedJsonPath
position.void
removeElementAtJsonPath
(JsonArray array, String jsonPath) Removes an element at the specifiedJsonPath
from the array.void
removeElementAtJsonPath
(JsonObject root, String jsonPath) Removes an element at the specifiedJsonPath
from the object.protected Object
selectValueUsingJsonPath
(JsonArray array, String jsonPath, boolean hasDefaultValue, Object defaultElement) protected Object
selectValueUsingJsonPath
(JsonObject obj, String jsonPath, boolean hasDefaultValue, Object defaultElement)
-
Constructor Details
-
JsonPathUtilsDefault
Constructor
-
-
Method Details
-
getSpincastConfig
-
getJsonManager
-
getJsonPathArrayIndexMax
protected int getJsonPathArrayIndexMax() -
getKeyMaxLengthWhenConvertingMapToJsonObject
protected int getKeyMaxLengthWhenConvertingMapToJsonObject() -
getElementAtJsonPath
Description copied from interface:JsonPathUtils
Gets an element from theJsonObject
, at the specifiedJsonPath
.- Specified by:
getElementAtJsonPath
in interfaceJsonPathUtils
- Returns:
- the element or
null
if not found.
-
getElementAtJsonPath
Description copied from interface:JsonPathUtils
Gets an element from theJsonObject
, at the specifiedJsonPath
.- Specified by:
getElementAtJsonPath
in interfaceJsonPathUtils
- Returns:
- the element or the
default element
if not found.
-
selectValueUsingJsonPath
protected Object selectValueUsingJsonPath(JsonObject obj, String jsonPath, boolean hasDefaultValue, Object defaultElement) -
getElementAtJsonPath
Description copied from interface:JsonPathUtils
Gets an element from theJsonArray
, at the specifiedJsonPath
.- Specified by:
getElementAtJsonPath
in interfaceJsonPathUtils
- Returns:
- the element or
null
if not found.
-
getElementAtJsonPath
Description copied from interface:JsonPathUtils
Gets an element from theJsonArray
, at the specifiedJsonPath
.- Specified by:
getElementAtJsonPath
in interfaceJsonPathUtils
- Returns:
- the element or the
default element
if not found.
-
selectValueUsingJsonPath
-
putElementAtJsonPath
Description copied from interface:JsonPathUtils
Puts an element in the object at the specifiedJsonPath
position. No clone is made, the element is put as is.The complete hierarchy to the final element is created if required.
- Specified by:
putElementAtJsonPath
in interfaceJsonPathUtils
-
removeElementAtJsonPath
Description copied from interface:JsonPathUtils
Removes an element at the specifiedJsonPath
from the object.- Specified by:
removeElementAtJsonPath
in interfaceJsonPathUtils
-
removeElementAtJsonPath
Description copied from interface:JsonPathUtils
Removes an element at the specifiedJsonPath
from the array.- Specified by:
removeElementAtJsonPath
in interfaceJsonPathUtils
-
isElementExists
Description copied from interface:JsonPathUtils
Does the object contain an element at theJsonPath
position (even ifnull
)?- Specified by:
isElementExists
in interfaceJsonPathUtils
-
isElementExists
Description copied from interface:JsonPathUtils
Does the array contain an element at theJsonPath
position (even ifnull
)?- Specified by:
isElementExists
in interfaceJsonPathUtils
-
processJsonPath
protected Object processJsonPath(JsonObject root, String jsonPath, JsonPathUtilsDefault.JsonPathProcessingType jsonPathProcessingType, Object valueToPut, boolean hasDefaultValue, Object defaultElement)
-