Re: [OT] is JSON all that great? - was Re: API Help

2017-06-16 Thread Erik
On 16/06/17 12:03, alister wrote: (The non native English speaker excuse is not an option for me) Does that mean it's mandatory for you? I'm confused :D :D E. -- https://mail.python.org/mailman/listinfo/python-list

Re: API Help

2017-06-16 Thread Tobiah
> I still think it _could_ be the output of a Python repr() or similar > (something that is expected to be evaluated as a Python expression). It may be valid fodder for python eval(), but if it came from repr() It would have used single quotes, yes? -- https://mail.python.org/mailman/listinfo/

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-16 Thread Ben Finney
Grant Edwards writes: > On 2017-06-16, Ben Finney wrote: > > JSON is designed to be *a strictly limited subset* of legal > > JavaScript that only defines data structures. The explicit goal is > > that it is statically parseable as non-executable data. > > That doesn't mean that it's reasonable/a

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-16 Thread Grant Edwards
On 2017-06-16, Ben Finney wrote: > alister writes: > >> Json is designed to be legal Javascript code & therefore directly >> executable so no parser is posible. > > JSON is designed to be *a strictly limited subset* of legal JavaScript > that only defines data structures. The explicit goal is tha

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-16 Thread alister
On Thu, 15 Jun 2017 21:17:05 +0100, Erik wrote: > On 15/06/17 15:10, Chris Angelico wrote: >> On Fri, Jun 16, 2017 at 12:00 AM, alister >> wrote: >>> Json is designed to be legal Javascript code & therefore directly >>> executable so no parser is posible. >>> >>> >> "no parser is possible"??? >

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-16 Thread alister
On Fri, 16 Jun 2017 00:10:58 +1000, Chris Angelico wrote: > On Fri, Jun 16, 2017 at 12:00 AM, alister > wrote: >> On Thu, 15 Jun 2017 22:27:40 +1000, Chris Angelico wrote: >> >>> On Thu, Jun 15, 2017 at 9:47 PM, Rhodri James >>> wrote: > 1) It is not secure. Check this out: > https://sta

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Ben Finney
alister writes: > Json is designed to be legal Javascript code & therefore directly > executable so no parser is posible. JSON is designed to be *a strictly limited subset* of legal JavaScript that only defines data structures. The explicit goal is that it is statically parseable as non-executab

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Chris Angelico
On Fri, Jun 16, 2017 at 6:58 AM, Grant Edwards wrote: > On 2017-06-15, Erik wrote: >> On 15/06/17 15:10, Chris Angelico wrote: >>> On Fri, Jun 16, 2017 at 12:00 AM, alister wrote: Json is designed to be legal Javascript code & therefore directly executable so no parser is posible.

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Chris Angelico
On Fri, Jun 16, 2017 at 6:17 AM, Erik wrote: > On 15/06/17 15:10, Chris Angelico wrote: >> >> On Fri, Jun 16, 2017 at 12:00 AM, alister >> wrote: >>> >>> Json is designed to be legal Javascript code & therefore directly >>> executable so no parser is posible. >>> >> >> "no parser is possible"???

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Grant Edwards
On 2017-06-15, Erik wrote: > On 15/06/17 15:10, Chris Angelico wrote: >> On Fri, Jun 16, 2017 at 12:00 AM, alister wrote: >>> Json is designed to be legal Javascript code & therefore directly >>> executable so no parser is posible. >>> >> >> "no parser is possible"??? > > I *think* alister meant

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Erik
On 15/06/17 15:10, Chris Angelico wrote: On Fri, Jun 16, 2017 at 12:00 AM, alister wrote: Json is designed to be legal Javascript code & therefore directly executable so no parser is posible. "no parser is possible"??? I *think* alister meant "so it is possible to not use a parser [librar

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Gene Heskett
On Thursday 15 June 2017 01:10:26 Marko Rauhamaa wrote: > Chris Angelico : > > XML is thus poorly suited to *most* forms of data, > > Correct. > > > > > > > aa > > qq > > qw > > qe > > as > > > > > > What does this represent? A generic XML parser has to cope with it. > > I gave this t

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Chris Angelico
On Fri, Jun 16, 2017 at 12:00 AM, alister wrote: > On Thu, 15 Jun 2017 22:27:40 +1000, Chris Angelico wrote: > >> On Thu, Jun 15, 2017 at 9:47 PM, Rhodri James >> wrote: 1) It is not secure. Check this out: https://stackoverflow.com/questions/1906927/xml- > vulnerabilities#1907500 >>> X

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread alister
On Thu, 15 Jun 2017 22:27:40 +1000, Chris Angelico wrote: > On Thu, Jun 15, 2017 at 9:47 PM, Rhodri James > wrote: >>> 1) It is not secure. Check this out: >>> https://stackoverflow.com/questions/1906927/xml- vulnerabilities#1907500 >> XML and JSON share the vulnerabilities that come from having

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Chris Angelico
On Thu, Jun 15, 2017 at 9:47 PM, Rhodri James wrote: >> 1) It is not secure. Check this out: >> https://stackoverflow.com/questions/1906927/xml-vulnerabilities#1907500 > XML and JSON share the vulnerabilities that come from having to parse > untrusted external input. XML then has some extra since

Re: API Help

2017-06-15 Thread Bradley Cooper
On Wednesday, June 14, 2017 at 6:10:55 PM UTC-4, Andre Müller wrote: > Am 14.06.2017 um 22:33 schrieb Bradley Cooper: > > 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.000

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-15 Thread Rhodri James
People seem to be having fun bashing XML, so I thought I'd wade in on its behalf. On 15/06/17 03:46, justin walters wrote: There are 2 main issues with XML: 1) It is not secure. Check this out: https://stackoverflow.com/questions/1906927/xml-vulnerabilities#1907500 XML and JSON share the vul

Re: API Help

2017-06-15 Thread Erik
On 15/06/17 01:30, Ray Cote wrote: On Wed, Jun 14, 2017 at 6:14 PM, Erik > wrote: If that makes it definitely JSON, then this makes it definitely Python ;) : >>> [{"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT-1-US","quantityAvailable

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-14 Thread Gregory Ewing
Michael Torrie wrote: I don't find JSON any more human readable than XML to be honest, perhaps less so because there's no way to define a formal schema to follow, at least that I'm aware of. You mean like this? http://json-schema.org/ One thing I like better about JSON than XML as a serialisa

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-14 Thread Marko Rauhamaa
Chris Angelico : > XML is thus poorly suited to *most* forms of data, Correct. > > > aa > qq > qw > qe > as > > > What does this represent? A generic XML parser has to cope with it. I > gave this to a few XML-to-JSON converters, and they all interpreted it > as some variant of {"asd

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-14 Thread Chris Angelico
On Thu, Jun 15, 2017 at 12:33 PM, Michael Torrie wrote: > To me JSON seems to hold no real benefits over other serialization > techniques, including the XML beast. XML may be verbose, but at least > XML data can be formally validated and formally transformed and queried, > which is certainly not t

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 7:33 PM, Michael Torrie wrote: > On 06/14/2017 05:06 PM, justin walters wrote: > > JSON in Python is such a joy! :) > > I understand that in this case the data is coming from a server in a > form intended for easy use with Javascript. But other than this type of > communi

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-14 Thread Grant Edwards
On 2017-06-15, Michael Torrie wrote: > On 06/14/2017 05:06 PM, justin walters wrote: >> JSON in Python is such a joy! :) 100% agreement here. > I understand that in this case the data is coming from a server in a > form intended for easy use with Javascript. But other than this > type of commun

Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 6:00 PM, Ned Batchelder wrote: > On Wednesday, June 14, 2017 at 7:06:39 PM UTC-4, justin walters wrote: > > JSON and Python dictionaries have nearly the exact same syntax. That's > why > > working with > > JSON in Python is such a joy! :) > > > > You can paste any valid JS

Re: [OT] is JSON all that great? - was Re: API Help

2017-06-14 Thread Skip Montanaro
On Wed, Jun 14, 2017 at 9:33 PM, Michael Torrie wrote: > To me JSON seems to hold no real benefits over other serialization > techniques, including the XML beast. I guess we'll have to agree to disagree. XML is the Devil's spawn, hiding its real intent inside layer after layer of tags. In contras

Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 4:40 PM, Grant Edwards wrote: > On 2017-06-14, justin walters wrote: > > > I should also specify that the data you have received is malformed. > > > > JSON should always have an object as the top level structure, not an > > array as in your data. > > Where is that require

[OT] is JSON all that great? - was Re: API Help

2017-06-14 Thread Michael Torrie
On 06/14/2017 05:06 PM, justin walters wrote: > JSON in Python is such a joy! :) I understand that in this case the data is coming from a server in a form intended for easy use with Javascript. But other than this type of communication, I don't see any good reason to choose JSON as a data interch

Re: API Help

2017-06-14 Thread Ned Batchelder
On Wednesday, June 14, 2017 at 7:06:39 PM UTC-4, justin walters wrote: > JSON and Python dictionaries have nearly the exact same syntax. That's why > working with > JSON in Python is such a joy! :) > > You can paste any valid JSON into a Python REPL and it will be interpreted > as a Python diction

Re: API Help

2017-06-14 Thread Ray Cote
On Wed, Jun 14, 2017 at 6:14 PM, Erik wrote: > On 14/06/17 22:54, Ray Cote wrote: > >> Definitely JSON: >> >>> > json.loads(“""[{"itemNumber":"75-5044","inventory":[{"wareho >> useCode":"UT-1-US","quantityAvailable":0.0},{"wa >> rehouseCode":"KY-1-US","quantityAvailable":0.000

Re: API Help

2017-06-14 Thread Erik
On 15/06/17 00:45, Chris Angelico wrote: Add all that kind of thing together, and you get my original conclusion that this is JSON. It's also perfectly parseable as various other things, but it's still most likely to be JSON. It "is JSON" but is also "parsable as various other things" yet is "m

Re: API Help

2017-06-14 Thread Chris Angelico
On Thu, Jun 15, 2017 at 8:34 AM, Erik wrote: > On 14/06/17 22:30, Chris Angelico wrote: >> >> It wouldn't be the repr() of a Python structure, as that wouldn't have >> all those trailing zeroes. > > > That depends on what class represents those float values. It doesn't have to > be the built-in fl

Re: API Help

2017-06-14 Thread Grant Edwards
On 2017-06-14, justin walters wrote: > I should also specify that the data you have received is malformed. > > JSON should always have an object as the top level structure, not an > array as in your data. Where is that requirement stated? RFC7159 explicitly states that a "conforming JSON text

Re: API Help

2017-06-14 Thread Erik
On 15/06/17 00:08, justin walters wrote: I should also specify that the data you have received is malformed. JSON should always have an object as the top level structure, not an array as in your data. So it's not JSON then? :D E. -- https://mail.python.org/mailman/listinfo/python-list

Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 4:06 PM, justin walters wrote: > > > On Wed, Jun 14, 2017 at 3:49 PM, Grant Edwards > wrote: > >> On 2017-06-14, Erik wrote: >> > On 14/06/17 22:54, Ray Cote wrote: >> >> Definitely JSON: >> > >> >> json.loads(“""[{"itemNumber":"75-5044","inventory":[{"wareho >> useC

Re: API Help

2017-06-14 Thread Rob Gaddi
On 06/14/2017 03:49 PM, Grant Edwards wrote: On 2017-06-14, Erik wrote: On 14/06/17 22:54, Ray Cote wrote: Definitely JSON: json.loads(“""[{"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT-1-US","quantityAvailable":0.0},{"warehouseCode":"KY-1-US","quantityAvailable":0.00

Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 3:49 PM, Grant Edwards wrote: > On 2017-06-14, Erik wrote: > > On 14/06/17 22:54, Ray Cote wrote: > >> Definitely JSON: > > > >> json.loads(“""[{"itemNumber":"75-5044","inventory":[{" > warehouseCode":"UT-1-US","quantityAvailable":0.0},{" > warehouseCode":

Re: API Help

2017-06-14 Thread Grant Edwards
On 2017-06-14, Erik wrote: > On 14/06/17 22:54, Ray Cote wrote: >> Definitely JSON: > >> json.loads(“""[{"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT-1-US","quantityAvailable":0.0},{"warehouseCode":"KY-1-US","quantityAvailable":0.0},{"warehouseCode":"TX-1-US

Re: API Help

2017-06-14 Thread Erik
On 14/06/17 22:30, Chris Angelico wrote: It wouldn't be the repr() of a Python structure, as that wouldn't have all those trailing zeroes. That depends on what class represents those float values. It doesn't have to be the built-in float. Same with the double-quotes instead of single-quotes o

Re: API Help

2017-06-14 Thread Erik
On 14/06/17 22:54, Ray Cote wrote: Definitely JSON: json.loads(“""[{"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT-1-US","quantityAvailable":0.0},{"warehouseCode":"KY-1-US","quantityAvailable":0.0},{"warehouseCode":"TX-1-US","quantityAvailable":14.

Re: API Help

2017-06-14 Thread Andre Müller
Am 14.06.2017 um 22:33 schrieb Bradley Cooper: > 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.0},{"warehouseCode":"KY-1-US","quantityAvailable":0.0},{"wareh

Re: API Help

2017-06-14 Thread Ray Cote
On Wed, Jun 14, 2017 at 4:33 PM, Bradley Cooper 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.0},{"warehouseCode":"KY-1-US"," > quantityAvailable":0.

Re: API Help

2017-06-14 Thread Peter Otten
Bradley Cooper wrote: > Yes it is not json, I did try that with no luck. What exactly did you try and how did it fail? -- https://mail.python.org/mailman/listinfo/python-list

Re: API Help

2017-06-14 Thread Erik
On 14/06/17 22:16, Matt Wheeler wrote: ? JSON keys are quoted Thanks Matt, I was confusing myself between JS source and JSON. Good to have this reminder (I always use libraries for reading and writing JSON in whatever language, so while I view it often I very rarely have to type it in direc

Re: API Help

2017-06-14 Thread Erik
On 14/06/17 22:18, Grant Edwards wrote: What makes it look like JSON to you? The fact that it _is_ valid JSON (at least according to the parsers I've tried on it, both locally and using things like jsonlint.com). And I tried it on the Python REPL. It's Python too. If someone wrote the follow

Re: API Help

2017-06-14 Thread Chris Angelico
On Thu, Jun 15, 2017 at 6:47 AM, Erik wrote: > On 14/06/17 21:38, Chris Angelico wrote: >> >> On Thu, Jun 15, 2017 at 6:33 AM, Bradley Cooper >> wrote: >>> >>> I am working with an API and I get a return response in this format. >>> >>> >>> >>> [{"itemNumber":"75-5044","inventory":[{"warehouseCod

Re: API Help

2017-06-14 Thread Matt Wheeler
On Wed, 14 Jun 2017 at 21:47 Erik wrote: > On 14/06/17 21:38, Chris Angelico wrote: > > On Thu, Jun 15, 2017 at 6:33 AM, Bradley Cooper > > wrote: > >> I am working with an API and I get a return response in this format. > >> > >> > >> > [{"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT

Re: API Help

2017-06-14 Thread Grant Edwards
On 2017-06-14, Erik wrote: > On 14/06/17 21:38, Chris Angelico wrote: >> On Thu, Jun 15, 2017 at 6:33 AM, Bradley Cooper >> wrote: >>> I am working with an API and I get a return response in this format. >>> >>> >>> {"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT-1-US","quantityAvailabl

Re: API Help

2017-06-14 Thread Erik
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 gues

Re: API Help

2017-06-14 Thread Bradley Cooper
Yes it is not json, I did try that with no luck. -- https://mail.python.org/mailman/listinfo/python-list

Re: API Help

2017-06-14 Thread Erik
On 14/06/17 21:38, Chris Angelico wrote: On Thu, Jun 15, 2017 at 6:33 AM, Bradley Cooper 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.0},{"warehouseCode":"KY-1-US"

Re: API Help

2017-06-14 Thread Chris Angelico
On Thu, Jun 15, 2017 at 6:33 AM, Bradley Cooper 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.0},{"warehouseCode":"KY-1-US","quantityAvailable":0.0},