Search code examples
neo4jcypherneo4j-apoc

Look up key from Json Object - Neo4j


In Neo4j , is there a APOC function that i can use to get value a from jsonObject by passing a Key. For example :

My JsonObject is : { "masterName" : {"name1" : "A1" , "name2" : "A2", "name3": "A3", "name4" : "A4"}}

and while importing my csv that has "name" field (values : name1, name2, name3, etc) for which I want to lookup above JsonObjet and get respective value to create nodes.


Solution

  • Assuming that you have your json in a field called myJSON, you could

    WITH ‘name1’ AS key, line
    WITH apoc.convert.fromJsonMap(line.myJSON)[key] AS name