[GRLUG] JSON parsing from bash

megadave megadave at gmail.com
Wed Nov 2 11:27:40 EDT 2011


Yeah, I'd actually already found that. Appreciate the try though...

jshon looks like a bear to install, and neither it nor its deps are in
debian squeeze repo's.

I played around with JSON.sh and ended up rewriting parts of it, and
actually managed to come up with something I can make do with. Its
ugly, but it works.


On Wed, Nov 2, 2011 at 11:20, Michael Mol <mikemol at gmail.com> wrote:
> 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.
>
> _______________________________________________
> grlug mailing list
> grlug at grlug.org
> http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
>

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