Package org.spincast.core.json
Interface JsonPathUtils
- All Known Implementing Classes:
JsonPathUtilsDefault
public interface JsonPathUtils
Utilities to deal with
JsonPaths
.-
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
.boolean
isElementExists
(JsonArray array, String jsonPath) Does the array contain an element at theJsonPath
position (even ifnull
)?boolean
isElementExists
(JsonObject obj, String jsonPath) Does the object contain an element at theJsonPath
position (even ifnull
)?void
putElementAtJsonPath
(JsonObjectOrArray root, String jsonPath, Object elementToAdd) 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 obj, String jsonPath) Removes an element at the specifiedJsonPath
from the object.
-
Method Details
-
getElementAtJsonPath
Gets an element from theJsonObject
, at the specifiedJsonPath
.- Returns:
- the element or
null
if not found.
-
getElementAtJsonPath
Gets an element from theJsonObject
, at the specifiedJsonPath
.- Returns:
- the element or the
default element
if not found.
-
getElementAtJsonPath
Gets an element from theJsonArray
, at the specifiedJsonPath
.- Returns:
- the element or
null
if not found.
-
getElementAtJsonPath
Gets an element from theJsonArray
, at the specifiedJsonPath
.- Returns:
- the element or the
default element
if not found.
-
putElementAtJsonPath
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.
-
removeElementAtJsonPath
Removes an element at the specifiedJsonPath
from the object. -
removeElementAtJsonPath
Removes an element at the specifiedJsonPath
from the array. -
isElementExists
Does the object contain an element at theJsonPath
position (even ifnull
)? -
isElementExists
Does the array contain an element at theJsonPath
position (even ifnull
)?
-