Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/21/2017 10:11 AM, Ned Batchelder wrote: I can only assume that the actual data being read is different than the data they put into the message here. --Ned. There was a typo in the file that I had made and saved; an extra comma before one of the ":". Apologies to the list for not catchi

Re: errors with json.loads

2017-09-21 Thread Ned Batchelder
On 9/21/17 12:18 PM, john polo wrote: Bill, Thanks for the reply. I wasn't sure how to get Python 2 through the cmd or IPython, so I went through ArcGIS, but it's mostly the same result: >>> file = open('books.json','r') >>> text = file.read() >>> text = json.loads(text) After the file.read

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/21/2017 4:24 AM, Thomas Jollans wrote: It looks to me like the root cause of the problem was that they copied the code from a web page, and the web page contained invalid JSON. Thank you, Thomas. John -- https://mail.python.org/mailman/listinfo/python-list

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/20/2017 6:40 PM, Dennis Lee Bieber wrote: On Wed, 20 Sep 2017 17:13:41 -0500, john polo declaimed the following: and the example code for reading the file is: file = open('books.json','r') What encoding is the file? I did a cut&paste from your post into a file, and the content

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/20/2017 5:58 PM, Bill wrote: Interesting problem, John. I have probably even less experience with json than you do, so I'm taking this as an opportunity to learn with you. Suggestions: 1. Try your example with Python 2 rather than Python 3. Bill, Thanks for the reply. I wasn't sure how

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/20/2017 5:56 PM, John Gordon wrote: In john polo writes: JSONDecodeError: Expecting ':' delimiter: line 5 column 50 (char 161) ?json.loads says that the method is for deserializing "s", with "s" being a string, bytes, or bytearray. In [24]: type(text) Out[24]: str So "text" seems to be

Re: errors with json.loads

2017-09-21 Thread Ned Batchelder
On 9/20/17 10:35 PM, Bill wrote: Ned Batchelder wrote: On 9/20/17 8:22 PM, Bill wrote: Apparenty an \xa0 byte corresponds to a "non-breaking space". What sort of white space characters are allowed in a json file ( tabs and newlines?)?  Just curious. These things can be looked up.  From RFC

Re: errors with json.loads

2017-09-21 Thread Thomas Jollans
On 2017-09-21 04:35, Bill wrote: > Ned Batchelder wrote: >> >> On 9/20/17 8:22 PM, Bill wrote: >>> Apparenty an \xa0 byte corresponds to a "non-breaking space". What >>> sort of white space characters are allowed in a json file ( tabs and >>> newlines?)?  Just curious. >> >> These things can be lo

Re: errors with json.loads

2017-09-20 Thread Bill
Ned Batchelder wrote: On 9/20/17 8:22 PM, Bill wrote: Apparenty an \xa0 byte corresponds to a "non-breaking space". What sort of white space characters are allowed in a json file ( tabs and newlines?)? Just curious. These things can be looked up. From RFC 7159 (https://tools.ietf.org/htm

Re: errors with json.loads

2017-09-20 Thread Christopher Reimer
> On Sep 20, 2017, at 5:03 PM, Stefan Ram wrote: > > Dennis Lee Bieber writes: >> After removing all the \xa0 bytes >> and trying to decode it I get... > > I did the same here, before I read your post. > I got the same results, but did not post them. > > Someone has posted programs with \xA

Re: errors with json.loads

2017-09-20 Thread Ned Batchelder
On 9/20/17 8:22 PM, Bill wrote: Apparenty an \xa0 byte corresponds to a "non-breaking space". What sort of white space characters are allowed in a json file ( tabs and newlines?)?  Just curious. These things can be looked up.  From RFC 7159 (https://tools.ietf.org/html/rfc7159): Insign

Re: errors with json.loads

2017-09-20 Thread Bill
Stefan Ram wrote: Dennis Lee Bieber writes: After removing all the \xa0 bytes and trying to decode it I get... Apparenty an \xa0 byte corresponds to a "non-breaking space". What sort of white space characters are allowed in a json file ( tabs and newlines?)? Just curious. Bill I did

Re: errors with json.loads

2017-09-20 Thread Bill
john polo wrote: Greetings, I am using IPython 6.1.0 with Python 3.6.2 on a Windows 7 machine. I am not a programmer. I am using a book called Python Data Analytics to try to learn some of Python. I am at a section for reading and writing JSON data. The example JSON file is: Listing 5-13.

Re: errors with json.loads

2017-09-20 Thread John Gordon
In john polo writes: > JSONDecodeError: Expecting ':' delimiter: line 5 column 50 (char 161) > ?json.loads says that the method is for deserializing "s", with "s" > being a string, bytes, or bytearray. > In [24]: type(text) > Out[24]: str > So "text" seems to be a string. Why does json.load

Re: errors with json.loads

2017-09-20 Thread Bill
Interesting problem, John. I have probably even less experience with json than you do, so I'm taking this as an opportunity to learn with you. Suggestions: 1. Try your example with Python 2 rather than Python 3. 2. Take your file and make it into a string literal in your program, and try cal

errors with json.loads

2017-09-20 Thread john polo
Greetings, I am using IPython 6.1.0 with Python 3.6.2 on a Windows 7 machine. I am not a programmer. I am using a book called Python Data Analytics to try to learn some of Python. I am at a section for reading and writing JSON data. The example JSON file is: Listing 5-13.  books.json [{"wri