apoc.map.clean

Function

apoc.map.clean(map MAP<STRING, ANY>, keys LIST<STRING>, values LIST<ANY>) - filters the keys and values contained in the given LIST<ANY> values.

Signature

apoc.map.clean(map :: MAP, keys :: LIST<STRING>, values :: LIST<ANY>) :: MAP

Input parameters

Name Type Default

map

MAP

null

keys

LIST<STRING>

null

values

LIST<ANY>

null

Usage Examples

The following removes empty string values from a map:

RETURN apoc.map.clean({name: "Cristiano Ronaldo", club: ""}, [], [""]) AS output;
Table 1. Results
Output
{
  "name": "Cristiano Ronaldo"
}

The following removes empty string values and the keys dob and country from a map:

RETURN apoc.map.clean(
    {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05"), club: ""},
    ["dob", "country"],
    [""]
) AS output;
Table 2. Results
Output
{
  "name": "Cristiano Ronaldo"
}