On 15/06/17 01:30, Ray Cote wrote:
On Wed, Jun 14, 2017 at 6:14 PM, Erik <pyt...@lucidity.plus.com
<mailto:pyt...@lucidity.plus.com>> wrote:
If that makes it definitely JSON, then this makes it definitely
Python ;) :
>>>
[{"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}]}]
[{'itemNumber': '75-5044', 'inventory': [{'quantityAvailable': 0.0,
'warehouseCode': 'UT-1-US'}, {'quantityAvailable': 0.0,
'warehouseCode': 'KY-1-US'}, {'quantityAvailable': 14.0,
'warehouseCode': 'TX-1-US'}, {'quantityAvailable': 4.0,
'warehouseCode': 'CA-1-US'}, {'quantityAvailable': 1.0,
'warehouseCode': 'AB-1-CA'}, {'quantityAvailable': 0.0,
'warehouseCode': 'WA-1-US'}, {'quantityAvailable': 0.0,
'warehouseCode': 'PO-1-CA'}]}]
So, I think we're agreed that it's definitely one or the other.
Well, that is the Python output from the json.loads() call; so yes…
No, it is not. It is the output from the Python REPL when the text from
the OP is pasted into it (*).
My point, if I really have to make it again, is that while the example
_could_ be JSON it _could_ equally also be a Python expression. Until
the OP says what format it is defined to be or posts an example with
something in it that is different between JSON and Python (a boolean,
for example) then you can't say it's *definitely* one or the other.
E.
(*) And to the various people who have responded "I don't eval() random
strings from the internet": firstly I eyeballed it to check there was
nothing nefarious in it before I pasted it into my interpreter;
secondly, I don't think anyone has suggested that is how the OP should
actually handle the data. We don't even know if what he posted was the
content of a received string or the result of already parsing his data
into a structure and printing it out somehow.
--
https://mail.python.org/mailman/listinfo/python-list