News for hackers. Stuff that matters.
Re:Jq – Work with JSON on the command line by 13of40 on Friday December 02, 2016 @05:33PM (#13092919)
I'm sure someone's going to throw a shoe at me for this, but...this sort of thing is why you want an object-oriented shell.

PS C:\> $x = ConvertFrom-Json -InputObject '[{"banana" : {"stem" : "brown", "peel" : "yellow", "flesh" : "white"}}]'

PS C:\> $x.banana.peel

yellow

Re:Jq – Work with JSON on the command line by taeric on Friday December 02, 2016 @11:28PM (#13094307)
I won't throw shoes. However, I do prefer anything that forces a commands output into text. Which JSON at least gets that right.

Specifically, if I have something that output objects, it is possible (and likely) that I can not persist that output to less and explore what is going on. Great if I already know exactly what I want. Terrible if I just want a visual exploration. Worse, if I can't dump it to file, I may have to constantly do some expensive operations just to find out what will give me the answer I want.

Re:Jq – Work with JSON on the command line by fabianfabian on Friday December 02, 2016 @05:41PM (#13092973)
$ echo '[{"banana" : {"stem" : "brown", "peel" : "yellow", "flesh" : "white"}}]' | jq '.[].banana.peel'

"yellow"

Re:Jq – Work with JSON on the command line by 13of40 on Friday December 02, 2016 @05:53PM (#13093037)
Come on now, you're missing the point. If the lingua franca of your shell is objects instead of text, you can import from whatever format you want and work with it in high fidelity:

PS C:\> $x = [XML]"<banana><stem>brown</stem><peel>yellow</peel><flesh>white</flesh></banana>"

PS C:\> $x.banana.peel

yellow

PS C:\> $x = ConvertFrom-Json -InputObject '[{"banana" : {"stem" : "brown", "peel" : "yellow", "flesh" : "white"}}]'

PS C:\> $x.banana.peel

yellow

PS C:\> $x = New-Object PSObject -Property @{banana = New-Object PSObject -Property @{stem = "brown"; peel = "yellow"; flesh = "white"}}

PS C:\> $x.banana.peel

yellow

PS C:\> $x = @{banana = @{stem = "brown"; peel = "yellow"; flesh = "white"}}

PS C:\> $x.banana.peel

yellow

Re:Jq – Work with JSON on the command line by fabianfabian on Friday December 02, 2016 @07:18PM (#13093426)
Good point, thanks for clarifying.
Re:Jq – Work with JSON on the command line by rhubarbquid on Friday December 02, 2016 @11:53PM (#13094383)
It might be interesting to try... but switching operating systems is kind of a big step just to try another shell.

Or is there some OO shell that works on Mac or Linux that I don't know about?

Re:Jq – Work with JSON on the command line by marmaduke on Saturday December 03, 2016 @10:42AM (#13096073)
Python?
Re:Jq – Work with JSON on the command line by awssailin on Friday December 02, 2016 @05:40PM (#13092969)
I don't want an object oriented shell but I have on occasion found jq to be very useful.