I have this query and as you firstName contains single quote Anthony O'Neil
:> g.addV('person')
.property('firstName', 'Anthony O'Neil')
.property('lastName', 'Andersen')
.property('age', 44)
Any Ideas how to escape it?
Escape the apostrophe using \
So your Gremlin becomes:
:> g.addV('person')
.property('firstName', 'Anthony O\'Neil')
.property('lastName', 'Andersen')
.property('age', 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
来源:https://stackoverflow.com/questions/44483185/how-to-escape-quotes-in-gremlin-queries