[triangle-zpug] python parsing JSON

Chris Church flyingfred0+trizpug at gmail.com
Thu Dec 25 04:02:13 UTC 2014


Hi Justin,

Your JSON data as pasted in the email seems to be missing the outmost
braces.  Also, the last comma after the "facts" dictionary will cause it to
fail to parse (
http://stackoverflow.com/questions/201782/can-you-use-a-trailing-comma-in-a-json-object
).

I've created a gist using your data (with the above issues fixed) and added
some sample code (Python 2.6 or later) to get the mac address:
https://gist.github.com/cchurch/a4c5778f5f8ced0b01d7

You may also want to join the trizpug mailing list (
https://mail.python.org/mailman/listinfo/trizpug/).  This one doesn't seem
to be used much any more.



On Wed, Dec 24, 2014 at 10:38 PM, Justin Parker <xjparkerx at gmail.com> wrote:

> I have no doubt that this has probably been answered in some form or
> fashion multiple times. Unfortunately, I am having a terrible time getting
> something to work.  Any help would be greatly appreciated.
>
> I have this json data:
>
> "log": {
>     "id": "http://192.168.43.81:8080/api/collections/nodes/node1/log",
>     "name": "log"
>   },
>   "tags": [],
>   "facts": {
>     "hardwareisa": "x86_64",
>     "macaddress": "08:00:27:e7:06:4d",
>     "architecture": "x86_64",
>     "hardwaremodel": "x86_64",
>     "processor0": "Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz",
>     "processorcount": "1",
>     "interfaces": "enp0s17,lo",
>     "ipaddress_enp0s17": "192.168.1.63"
>   },
>
> I'm trying to parse this data to get the value for macaddress using the
> standard json library.
>
> Again any help would be greatly appreciated.
> Justin
>
> _______________________________________________
> triangle-zpug mailing list
> triangle-zpug at starship.python.net
> http://starship.python.net/mailman/listinfo/triangle-zpug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://starship.python.net/pipermail/triangle-zpug/attachments/20141224/2b7d1ce2/attachment.html>


More information about the triangle-zpug mailing list