On Thu, Jun 15, 2017 at 6:47 AM, Erik <pyt...@lucidity.plus.com> wrote: > On 14/06/17 21:38, Chris Angelico wrote: >> >> On Thu, Jun 15, 2017 at 6:33 AM, Bradley Cooper >> <b...@midwestaftermarket.com> wrote: >>> >>> I am working with an API and I get a return response in this format. >>> >>> >>> >>> [{"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT-1-US","quantityAvailable":0.0000000000000},{"warehouseCode":"KY-1-US","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}]}] >>> >>> What is the best way to read through the data? >> >> >> That looks like JSON. > > > If the keys weren't quoted, I'd agree with you. > > It looks like a REPL representation of a Python structure to me (list of > dicts where the values could also be lists of dicts ... > > What makes it look like JSON to you? (I'm not arguing, I'm asking what I've > missed).
JSON, unlike JavaScript/ECMAScript itself, requires the keys to be quoted. (It's legal to quote them in JS, but conventionally, people omit the quotes where possible.) It wouldn't be the repr() of a Python structure, as that wouldn't have all those trailing zeroes. But you probably could parse it with literal_eval all the same. Still, I'd go with JSON if at all possible. ChrisA -- https://mail.python.org/mailman/listinfo/python-list