Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-13-2022 02:44 AM
Hello everyone,
for a cypher statement that I am coding I would love to know whether there is a cypher functionality like in javascript's [ key ] : value.
I am querying an object which is build as followed:
{
"Id": "Floor",
"IdType": "string",
"Value": "",
"Unit": "none",
}
And I would like to have a result which is built with the node's property "Id" as key and the node's property "Value" as value:
{
//Id : Value
"Floor": "XYZ"
}
Solved! Go to Solution.
01-15-2022 03:47 AM
Hi klug,
I hope this snippet of query can help you:
with obj.Id as keyName
match (n)
where n[keyName] is not null
with n,keyName,n[keyName] as value
with apoc.map.fromPairs([[keyName,value]]) as ns
return ns
01-15-2022 03:47 AM
Hi klug,
I hope this snippet of query can help you:
with obj.Id as keyName
match (n)
where n[keyName] is not null
with n,keyName,n[keyName] as value
with apoc.map.fromPairs([[keyName,value]]) as ns
return ns
01-17-2022 12:36 AM
Thanks @filantrop! The apoc function fromPairs is the perfect fit for my problem.
Thanks for the fast and useful answer
All the sessions of the conference are now available online