how to escape quotes in gremlin queries

后端 未结 2 1963
暗喜
暗喜 2021-01-12 20:57

I have this query and as you firstName contains single quote Anthony O\'Neil

:> g.addV(\'person\')
    .property(\'firstName\', \'Anthony O\'Neil\')
    .         


        
相关标签:
2条回答
  • 2021-01-12 21:44

    Found out the answer

    for encoding use this: encodeURIComponent("Anthony O'Neil").replace(/[!'()*]/g, escape) and the output is: Anthony%20O%27Neil

    for decoding use this: decodeURIComponent("Anthony%20O%27Neil") and you will get back Anthony O'Neil

    if you just want to escape the single quote use this for encoding: "Anthony O'Neill".replace(/[!'()*]/g, escape) output: Anthony O%27Neill

    and the same function above for decoding

    0 讨论(0)
  • 2021-01-12 21:47

    Escape the apostrophe using \

    So your Gremlin becomes:

    :> g.addV('person')
        .property('firstName', 'Anthony O\'Neil')
        .property('lastName', 'Andersen')
        .property('age', 44)
    
    0 讨论(0)
提交回复
热议问题