apoc.convert.toSortedJsonMap

Function APOC Core

apoc.convert.toSortedJsonMap(node|map, ignoreCase:true) - returns a JSON map with keys sorted alphabetically, with optional case sensitivity

Signature

apoc.convert.toSortedJsonMap(value :: ANY?, ignoreCase = true :: BOOLEAN?) :: (STRING?)

Input parameters

Name Type Default

value

ANY?

null

ignoreCase

BOOLEAN?

true

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;
Table 1. 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;
Table 2. Results
Output

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