
Jid – Drill down JSON data incrementally - jamslater
https://github.com/simeji/jid
======
fiatjaf
Ok, 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/)

~~~
nacs
In less that 24 hours since the post, you've managed to shoehorn jq in (looks
like about 6 hours of work from commits). Nice work! Really shows the power of
OSS.

------
Animats
The 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.

~~~
ubernostrum
Except JSON has a huge advantage Lisp doesn't: it's close to, or in some cases
identical to, the data-structure syntax of several popular programming
languages. Lisp's particular s-expression syntax is not close to or identical
to any programming language other than Lisp.

In other words: once you decide you don't want to program in Lisp, Lisp's way
of representing data stops being a useful syntax for representing your data.
Undervaluing this realization (and worse, reacting smugly when interacting
with people who don't share your undervaluing of this) is a big part of the
gulf between Lispers and the rest of the world.

~~~
paulddraper
> not close to or identical to any programming language other than Lisp.

It's close to the Lisps, Scheme, Racket, Clojure, and many others.

You are correct that the popularity of Ruby, Python, and JavaScript has
eclipsed the popularity of these languages, and so the popularity of JSON has
eclipsed that of s-expressions.

~~~
ubernostrum
Scheme, Racket and Clojure are all Lisp-family languages if not arguably Lisps
in and of themselves.

~~~
paulddraper
By that token, JavaScript and PHP are C-family languages

[https://en.wikipedia.org/wiki/List_of_C-
family_programming_l...](https://en.wikipedia.org/wiki/List_of_C-
family_programming_languages)

I don't see where checkbox ticking will get us.

~~~
ubernostrum
They are C-family languages.

It should be unsurprising that languages which have adopted Lisp's
syntax/programming model to a larger degree will also naturally find Lisp's
syntax/programming model to work for them, while languages that haven't...
won't.

~~~
paulddraper
Agreed.

------
dorianm
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.

~~~
fiatjaf
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.

~~~
dorianm
How 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 ;)

~~~
hyperpallium
jq 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_
I 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

------
amelius
Would be nice to have this in Chromium/Firefox developer tools.

------
mypalmike
I 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)

------
pka
Shameless, but related plug [0] - an interactive JSON log viewer.

[0]
[https://github.com/pkamenarsky/sherlock](https://github.com/pkamenarsky/sherlock)

------
asimjalis
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](https://github.com/nathanmarz/specter)

~~~
bbrks
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

------
nerdponx
When 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?

------
Ancient
If only Jid & jq could get married <3 :)

~~~
chrisan
See
[https://news.ycombinator.com/item?id=13099819](https://news.ycombinator.com/item?id=13099819)

------
fiatjaf
Does it use jq internally?

~~~
fiatjaf
The answer is NO for jid, but jiq uses jq internally:
[https://github.com/fiatjaf/jiq](https://github.com/fiatjaf/jiq)

------
showkhill
J-drilla

