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

Can dashes be escaped in entity names? #202

Closed
ve3ied opened this issue Oct 24, 2013 · 4 comments
Closed

Can dashes be escaped in entity names? #202

ve3ied opened this issue Oct 24, 2013 · 4 comments
Labels

Comments

@ve3ied
Copy link

ve3ied commented Oct 24, 2013

This may just be a lack of my understanding, but while trying to parse a response to get tag values for a tagname, unfortunately someone used a dash in one of the tagnames which is interpreted by jq. Is there any way to escape this from being interpreted by jq?

I used something like this:

jq '.queries[0] | .results[0] | .tags | .bad-tag | .[]'

..where bad-tag doesn't work. I've also tried: .["bad-tag"] and various other things to try to work around it, but can't find a solution..

Any suggestions?

@ve3ied
Copy link
Author

ve3ied commented Oct 24, 2013

Actually, I think it does work. I hadn't escaped the variable I used properly in the shell script.

Thanks.

@ve3ied ve3ied closed this as completed Oct 24, 2013
@ghost
Copy link

ghost commented Apr 2, 2014

How did you get this to work, please? I have the following problem using a dash in a tag name:

$ cat info.json | jq --raw-output '.messages[0] | .headers | .user-agent '
error: agent is not defined
.messages[0] | .headers | .user-agent
                                ^^^^^
1 compile error

I've tried using backslashes, HTML escapes, and @ symbols.

@ghost
Copy link

ghost commented Apr 2, 2014

Found the solution on this page:

cat info.json | jq --raw-output '.messages[0] | .headers | .["user-agent"] '

@ve3ied
Copy link
Author

ve3ied commented Apr 2, 2014

Right, that's what I did..

Cheers.

On Wed, Apr 02, 2014 at 12:56:52PM -0700, Steve Onetwothreefourfivesix wrote:

Found the solution on this page:

cat info.json | jq --raw-output '.messages[0] | .headers | .["user-agent"] '

Reply to this email directly or view it on GitHub:
#202 (comment)

Bill Duncan,
bduncan@beachnet.org
+1 416 697-9315

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