Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping forward slash #51

Closed
kszafran opened this issue Nov 26, 2019 · 2 comments
Closed

Escaping forward slash #51

kszafran opened this issue Nov 26, 2019 · 2 comments
Labels

Comments

@kszafran
Copy link

I accidentally stumbled upon another incompatibility with jq (jq-1.6):

$ jq -n '"\/"'
"/"

with jackson-jq (0.0.11):

...
Caused by: java.lang.IllegalStateException: Unexpected escape char: /
	at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.StringInterpolation(JsonQueryParser.java:1428)
	at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.PrimaryExpression(JsonQueryParser.java:512)
	at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.BinaryOperatorExpression(JsonQueryParser.java:271)
	at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.TupleExpression(JsonQueryParser.java:244)
	at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.JsonQuery(JsonQueryParser.java:171)
	at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.Start(JsonQueryParser.java:162)
	at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.compile(JsonQueryParser.java:23)
	at net.thisptr.jackson.jq.JsonQuery.compile(JsonQuery.java:38)
	... 3 more

It seems that jq allows escaping forward slashes, and JSON does too (https://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped). Perhaps it was carried over from JavaScript, where escaping / might be required when you want to write a regex like /\//...

@eiiches
Copy link
Owner

eiiches commented Nov 27, 2019

Thanks for reporting this. I didn't know \/ is valid in a JSON string...
I'll probably work on this issue sometime in the next week :)

@eiiches
Copy link
Owner

eiiches commented Dec 8, 2019

Fix landed in 0.0.12 and 1.0.0-preview.20191208

@eiiches eiiches closed this as completed Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants