apoc.map.flatten

Function APOC Core

apoc.map.flatten(map, delimiter:'.') yield map - flattens nested items in map using dot notation

Signature

apoc.map.flatten(map :: MAP?, delimiter = . :: STRING?) :: (MAP?)

Input parameters

Name Type Default

map

MAP?

null

delimiter

STRING?

.

Usage Examples

The following flattens a nested map using the default . delimiter:

RETURN apoc.map.flatten({
  person: {
    name: "Cristiano Ronaldo",
    club: {
      name: "Juventus",
      founded: 1897
    }
  }
}) AS output;
Table 1. Results
Output
{
  "person.name": "Cristiano Ronaldo",
  "person.club.founded": 1897,
  "person.club.name": "Juventus"
}

The following flattens a nested map using the / delimiter:

RETURN apoc.map.flatten({
  person: {
    name: "Cristiano Ronaldo",
    club: {
      name: "Juventus",
      founded: 1897
    }
  }
}, "/") AS output;
Table 2. Results
Output
{
  "person/club/name": "Juventus",
  "person/club/founded": 1897,
  "person/name": "Cristiano Ronaldo"
}