6 ms·
Jid – Drill down JSON data incrementally
- Ancient 10y agoIf only Jid & jq could get married <3 :)
- chrisan 10y agoSee https://news.ycombinator.com/item?id=13099819 https://news.ycombinator.com/item?id=13099819
- amelius 10y agoWould be nice to have this in Chromium/Firefox developer tools.
- dorianm 10y agoI 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.
- fiatjaf 10y agoYou 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.
- wellsjohnston 10y agoI made a gui for this https://github.com/wellsjo/JSON-Splora https://github.com/wellsjo/JSON-Splora
- dorianm 10y agoHow would you do a `data.keys.sort` with jq? Here I don't have to learn a new programming language or hack around with UNIX pipes ;)
- lumpypua 10y ago`keys|sort` in jq.
- dorianm 10y agoNice! Thanks
- hyperpallium 10y agojq has sort and sort_by(exp). Its | is a jq operator, not a unix pipe. It's true it's a new lang, and although simple, I often have to look things up. It might be nice to have a jq REPL, so needn't quote, and easier to keep state around.
- voltagex_ 10y agoI find jq syntax tricky, and it's difficult to work out what I need to get to specific elements. I guess I'm more used to things like XPath. Seconding the request for a REPL
- Animats 10y agoThe JSON crowd is re-inventing LISP. Originally, JSON was a subset of what you could pass to "eval()". Yesterday, state machine programming in JSON. Today, an inspector.
- fiatjaf 10y agoDo you think that is bad? Many people like LISP.
- cle 10y agoI think Lisp folks complain because so much effort has been spent to converge on the same stuff we already had. When it comes to data serialization, over many decades we've invented many formats, and they usually go off on tangents and then converge on essentially the same stuff. Lispers respond: "We told you so."
- vikiomega9 10y agoCan you point me to an example of a serialization that was reinvented?
- adzm 10y agoJSON vs S-expressions
- vikiomega9 10y agoAh I always figured S-expressions were "representations" as opposed to "serializations", but that makes sense. Any others?
- woodruffw 10y agoA new formulation of Greenspun's tenth rule, perhaps. [0] [0]: https://en.wikipedia.org/wiki/Greenspun's_tenth_rule https://en.wikipedia.org/wiki/Greenspun's_tenth_rule
- 10y ago
- asimjalis 10y agoHow 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 https://github.com/nathanmarz/specter
- bbrks 10y agojq 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
- gwu78 10y agoecho '{"users":[{"name":"s1","id":1},{"name":"s2","id":2}]}' |exec tr '{' '\12'|exec sed '/name/!d;s/\"//g;s/}.*//' output: name:s1,id:1 name:s2,id:2
- fiatjaf 10y agoDoes it use jq internally?
- nerdponx 10y agoWhen should/shouldn't I use this over jq? Is the main difference that this is interactive while jq is not? How similar/different is the syntax?
- pka 10y agoShameless, but related plug [0] - an interactive JSON log viewer. [0] https://github.com/pkamenarsky/sherlock https://github.com/pkamenarsky/sherlock
- mypalmike 10y agoI built a similar thing recently with python. Not complete, but a bunch of stuff does work. It's modeled on interacting on-device with a JunOS or Cisco config. Probably the most interesting feature is text completion. https://github.com/mypalmike/ijsoned https://github.com/mypalmike/ijsoned
- showkhill 10y agoJ-drilla
- fiatjaf 10y agoOk, I've just hacked a version of this that uses jq[0] underneath, so you can do all the sorts of fancy queries jid originally doesn't support: https://github.com/fiatjaf/jiq https://github.com/fiatjaf/jiq [0]: https://stedolan.github.io/jq/manual/ https://stedolan.github.io/jq/manual/