apoc.convert.getJsonPropertyMap
Syntax |
|
||
Description |
Converts a serialized JSON object from the property of the given |
||
Arguments |
Name |
Type |
Description |
|
|
The node containing a JSON stringified map. |
|
|
|
The property key to convert. |
|
|
|
A JSON path expression used to extract a certain part from the node property string. The default is: ``. |
|
|
|
JSON path options: ('ALWAYS_RETURN_LIST', 'AS_PATH_LIST', 'DEFAULT_PATH_LEAF_TO_NULL', 'REQUIRE_PROPERTIES', 'SUPPRESS_EXCEPTIONS') The default is: |
|
Returns |
|
Usage examples
The examples in this section are based on the following sample graph:
CREATE (:Person {json:'{a:[1,2,3]}'});
MATCH (p:Person)
RETURN apoc.convert.getJsonPropertyMap(p, "json") AS output;
Output |
---|
{a: [1, 2, 3]} |
Moreover, we can customize the Json path options, adding as third parameter (pathOptions
) a list of strings,
where the strings are based on Enum<Option>.
The default value is ["SUPPRESS_EXCEPTIONS", "DEFAULT_PATH_LEAF_TO_NULL"]
. Note that we can also insert []
, that is "without options".
So, with a (n:JsonPathNode {prop: '{"columns":{"col2":{"_id":"772col2"}}}'})
we can execute (with default pathOptions):
MATCH (n:JsonPathNode) RETURN apoc.convert.getJsonPropertyMap(n, 'prop', '$.columns.col2') AS output;
output |
---|
{ "_id": "772col2" } |
or, with custom path options:
MATCH (n:JsonPathNode) RETURN apoc.convert.getJsonPropertyMap(n, 'prop', '$.columns.col2', ['ALWAYS_RETURN_LIST']) AS path
Failed to invoke function apoc.convert.getJsonPropertyMap : Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.LinkedHashMap<java.lang.Object,java.lang.Object> out of START_ARRAY token at [Source: UNKNOWN; line: -1, column: -1] |
---|