Package org.forgerock.audit.util
Class JsonValueUtils
java.lang.Object
org.forgerock.audit.util.JsonValueUtils
Contains some JsonValue Utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonValueExpands a Json Object Map, where the keys of the map are theJsonPointers and the values are the value theJsonPointerresolves to.static StringextractValueAsString(JsonValue json, String fieldName) Extracts String representation of field identified byfieldNamefromjsonobject.static StringextractValueAsString(JsonValue json, JsonPointer pointer) Extracts String representation of field identified bypointerfromjsonobject.Flattens aJsonValueto a Map, where the keys of the Map areJsonPointers and the values are the value theJsonPointers resolve to.
-
Method Details
-
expand
Expands a Json Object Map, where the keys of the map are theJsonPointers and the values are the value theJsonPointerresolves to. For Example, the following key-value pairs/object/array/0 , "test" /object/array/1 , "test1" /string , "stringVal" /boolean , false /number , 1 /array/0 , "value1" /array/1 , "value2"will produce the following json object{ "object" : { "array" : ["test", "test1"] }, "string" : "stringVal", "boolean" : false, "number" : 1, "array" : ["value1", "value2"] }- Parameters:
object- the Json Object Map containing theJsonPointers and values- Returns:
- the
JsonValueexpanded from the object map
-
flatten
Flattens aJsonValueto a Map, where the keys of the Map areJsonPointers and the values are the value theJsonPointers resolve to. For Example, the following JsonValue{ "object" : { "array" : ["test", "test1"] }, "string" : "stringVal", "boolean" : false, "number" : 1, "array" : ["value1", "value2"] }will produce the following Map key-value pairs/object/array/0 , "test" /object/array/1 , "test1" /string , "stringVal" /boolean , false /number , 1 /array/0 , "value1" /array/1 , "value2" -
extractValueAsString
Extracts String representation of field identified byfieldNamefromjsonobject.JsonValuetransformers are applied up tofieldNamebut not to its components.- Parameters:
json- theJsonValueobject from which to extract a value.fieldName- the field identifier in a form consumable byJsonPointer.- Returns:
- A non-null String representation of the field's value. If the specified field is not present or has a null value, null will be returned.
-
extractValueAsString
Extracts String representation of field identified bypointerfromjsonobject.JsonValuetransformers are applied up tofieldNamebut not to its components.- Parameters:
json- theJsonValueobject from which to extract a value.pointer- the field identifier as aJsonPointer.- Returns:
- A non-null String representation of the field's value. If the specified field is not present or has a null value, null will be returned.
-