[GRLUG] JSON parsing from bash

Michael Mol mikemol at gmail.com
Wed Nov 2 11:20:11 EDT 2011


On Wed, Nov 2, 2011 at 12:55 AM, megadave <megadave at gmail.com> wrote:
> Anyone have any familiarity with JSON?
>
> I'm trying to make some automated queries to a device which returns
> the results in JSON form.
>
> I'm trying to find a way to flatten the JSON data, eg
>
> Eg, for something like this:
>
> {
> "foo" : "bar",
> "beep" : 67,
> "snizz" : {
> "bit" : 5,
> "lit" : 7,
> "bat" " 23
> },
> "neep" : {
> "bit" : "red",
> "bat" : "blue",
> "cat" : 34
> },
> }
>
> I'd love to have a util that would give me:
>
> foo:bar
> beep:67
> snizz.bit:5
> snizz.lit:7
> snizz.bat:23
> neep.bit:red
> neep.bat:blue
> neep.cat:34

May not be what you're looking for, but a good start would be to use
some JSON libraries:

http://kmkeen.com/jshon/
https://github.com/dominictarr/JSON.sh

(found at http://json.org/ )

--
:wq

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the grlug mailing list