Giter VIP home page Giter VIP logo

Comments (10)

stedolan avatar stedolan commented on July 25, 2024 12

@theoreticaLee you can use keys with slashes, but you'll have to use explicit strings as the keys:

jq '.slash/key' won't work, but jq '.["slash/key"]' will.
jq '{slash/key}' won't work, but jq '{"slash/key"}' will.

from jq.

stedolan avatar stedolan commented on July 25, 2024 4

You can use the following syntax:

jq '.feed.entry[] | {"group": .["media$group"]}'

The {foo} syntax is shorthand for this, but you need to use the longhand version if there are unusual characters in the field name.

from jq.

stedolan avatar stedolan commented on July 25, 2024 2

Now (if you build master) you can use:

jq '.feed.entry[] | {"media$group"}'

from jq.

Jean-Baptiste-Lasselle avatar Jean-Baptiste-Lasselle commented on July 25, 2024 2

@theoreticaLee you can use keys with slashes, but you'll have to use explicit strings as the keys:

jq '.slash/key' won't work, but jq '.["slash/key"]' will.
jq '{slash/key}' won't work, but jq '{"slash/key"}' will.

honestly love that one : just so useful today, using hashicorp vault api...

from jq.

v6dou avatar v6dou commented on July 25, 2024 2

None of the above solutions worked, I had to generate a jqparams.txt file using a "heredoc" and put environment variables in it, then pass that using jq --from-file jqparams.txt.

Would be nice to see this program play better with bash primitives.

from jq.

Chealer avatar Chealer commented on July 25, 2024 1

For what it's worth, to access a sub-element where the sub-key has a slash:
jq '.devDependencies."@angular/cli"' package.json

from jq.

scheibo avatar scheibo commented on July 25, 2024

Along the same lines - I'm getting errors when the keys I'm trying to query for have '.' or ':' in them - ie/ 'foo.bar.baz:8008' is a key I'm trying to pull out out some JSON.

from jq.

edap avatar edap commented on July 25, 2024

ok, thanks for your answer

from jq.

theoreticaLee avatar theoreticaLee commented on July 25, 2024

Yeah, it would be great to add in escaping ability. I'm running into trouble with facebook's api as some results have keys with forward slash in them :/

from jq.

v6dou avatar v6dou commented on July 25, 2024

@Jean-Baptiste-Lasselle I'm dealing with the same thing, in the list of accessors at sys/auth

from jq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.