apoc.convert.toSortedJsonMap

Details

Syntax

apoc.convert.toSortedJsonMap(value [, ignoreCase ])

Description

Converts a serialized JSON object from the property of a given NODE into a Cypher MAP.

Arguments

Name

Type

Description

value

ANY

The value to convert into a stringified JSON map.

ignoreCase

BOOLEAN

Whether or not to ignore the case of the keys when sorting. The default is: true.

Returns

STRING

Usage examples

The following converts a map to a JSON map with keys sorted alphabetically, ignoring case sensitivity:

WITH {b:8, d:3, a:2, E: 12, C:9} as map
RETURN apoc.convert.toSortedJsonMap(map) as output;
Results
Output

"{\"a\":2,\"b\":8,\"C\":9,\"d\":3,\"E\":12}"

The following converts a map to a JSON map with keys sorted alphabetically, with case sensitivity:

WITH {b:8, d:3, a:2, E: 12, C:9} as map
RETURN apoc.convert.toSortedJsonMap(map, false) as output;
Results
Output

"{\"C\":9,\"E\":12,\"a\":2,\"b\":8,\"d\":3}"