apoc.map.fromValues

This function is deprecated. Use Cypher’s map comprehension instead.

Details

Syntax

apoc.map.fromValues(values)

Description

Creates a MAP from the alternating keys and values in the given LIST<ANY>.

Arguments

Name

Type

Description

values

LIST<ANY>

A list of keys and values listed pairwise to create a map from.

Returns

MAP

Usage examples

The following creates a MAP from alternating keys and values in a list:

apoc.map.fromValues
RETURN apoc.map.fromValues([
    "name", "Cristiano Ronaldo",
    "age", date("1985-02-05")
]) AS output;
Cypher’s Map Comprehension
WITH ["name", "Cristiano Ronaldo", "age", date("1985-02-05")] AS values
RETURN { i IN range(0, size(values) / 2, 2) | values[i]: values[i + 1] } AS output;
Results
output
{
  "name": "Cristiano Ronaldo",
  "age": "1985-02-05"
}