Live data from Hacker News

Jid – Drill down JSON data incrementally

github.com

1–10 of 55 posts

Re: Jid – Drill down JSON data incrementally

#6
How can I use wildcards in queries?

For example consider this.

    echo '{"users":[{"name":"s1","id":1},{"name":"s2","id":2}]}'|jid 
I can query users[0].id or users[1].id. How can I get all the ids? I tried users[*].id which didn’t work.

In Clojure I use specter [1] for this which is able to handle wildcards using ALL.

[1] https://github.com/nathanmarz/specter

Re: Jid – Drill down JSON data incrementally

#7

How can I use wildcards in queries? For example consider this. echo '{"users":[{"name":"s1","id":1},{"name":"s2","id":2}]}'|jid I can query users[0].id or users[1].id. How can I get all the ids? I tried users[*].id which didn’t work. In Clojure I use specter [1] for this which is able to handle wildcards using ALL. [1] https://github.com/nathanmarz/specter

jq uses empty square brackets as a way of accessing all of an arrays elements. Not sure if this tool uses the same syntax?

E.g. users[].id

Re: Jid – Drill down JSON data incrementally

#10
post #4

I personally like digging in a ruby console, e.g.: require 'json' require 'open-uri' data = JSON.load(open("https://api.github.com/users/Dorian")) data.keys data.first data["public_repos"] etc.

You personally like to suffer.

I used to do that in Python, but it is a pain. jq is great for these things, and jid seems to be also.

Post reply on HN