On 14/06/17 21:47, Erik wrote:
What makes it look like JSON to you? (I'm not arguing, I'm asking what I've missed).

If I cut-and-paste the OP's structure into the REPL, it replies with a valid Python structure that's equivalent (albeit with single-quotes instead of double-quotes).

So I guess I'm only partially arguing. I agree that it therefore looks like it's not REPL output, but perhaps the actual input that the OP needs to deal with (from whatever). Still not exclusively JSON though ;)





To the OP: start a Python shell and paste your structure as follows:

foo = [{"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT1-US","quantityAvailable":0.0000000000000},{"warehouseCode":"KY1US","quantityAvailable":0.0000000000000},{"warehouseCode":"TX-1-US","quantityAvailable":14.0000000000000},{"warehouseCode":"CA-1-US","quantityAvailable":4.0000000000000},{"warehouseCode":"AB-1-CA","quantityAvailable":1.0000000000000},{"warehouseCode":"WA-1-US","quantityAvailable":0.0000000000000},{"warehouseCode":"PO-1-CA","quantityAvailable":0.0000000000000}]}]

Now you can interrogate your structure interactively to see what might be a good way of "reading through it" (you don't say what you actually want to do).

What does "foo[0]" show.
What does "foo[0]['inventory'] show?
What does "foo[0]['inventory'][1] show?
What does "foo[0]['inventory'][1]['warehouseCode'] show?

It's just lists (arrays) and dicts (key/value pairs).

E.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to