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