apoc.map.unflatten

Details

Syntax

apoc.map.unflatten(map [, delimiter ])

Description

Unflattens items in the given MAP to nested items. This function is the reverse of the apoc.map.flatten function.

Arguments

Name

Type

Description

map

MAP

The map to unflatten.

delimiter

STRING

The delimiter used to separate the levels of the flattened map. The default is: ..

Returns

MAP

Usage Examples

Using the following map and the default . delimiter:

RETURN apoc.map.unflatten({
  `person.name`: "Cristiano Ronaldo",
  `person.club.founded`: 1897,
  `person.club.name`: "Juventus"
}) AS output;

will be returned:

Results
Output
{
  "person": {
    "club": {
      "founded": 1897,
      "name": "Juventus"
    },
    "name": "Cristiano Ronaldo"
  }
}

Using the following map and a custom delimiter, that is /é哈:

RETURN apoc.map.unflatten({
  `person/é哈firstName`: "Cristiano",
  `person/é哈lastName`: "Ronaldo",
  `person/é哈club/é哈founded`: 1897,
  `person/é哈club/é哈name`: "Juventus"
}, '/é哈') AS output;

will be returned:

Results
Output
{
  "person": {
    "club": {
      "name": "Juventus",
      "founded": 1897
    },
    "firstName": "Cristiano",
    "lastName": "Ronaldo"
  }
}