how to escape quotes in gremlin queries

后端 未结 2 1964
暗喜
暗喜 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

提交回复
热议问题