Neo4j how to handle special characters like ” \ in Cypher statements

后端 未结 2 1708
-上瘾入骨i
-上瘾入骨i 2020-12-21 05:15

I am using py2neo to load JSON data into Neo4j as chyper statements. My problem is that sometimes there are signs as “ ‘ \\ etc in the strings I want to impor

2条回答
  •  庸人自扰
    2020-12-21 05:45

    If you want to include double quotes, you can wrap in single quotes:

    CREATE (n:Node {name:'hello " world'}) 
    RETURN n.name
    
    n.name
    hello " world
    

    If you want to include single quotes, you can wrap in double quotes:

    CREATE (n:Node {name:"hello ' world"}) 
    RETURN n.name
    
    n.name
    hello ' world
    

    If it's more complicated than that, you can escape the character:

    CREATE (n:Node {name:"hello \" world"}) 
    RETURN n.name
    
    n.name
    hello " world
    

    You can also include backslashes by escaping them:

    CREATE (n:Node {name:"hello \\ world"}) 
    RETURN n.name
    
    n.name
    hello \ world
    

提交回复
热议问题