Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 23:22, Martin A. Brown wrote: arr = json.loads('{ "name": "Joe", "address": "111 Street" }') arr.get('address') Here are some notes about why: # -- You will notice I used a variable called 'arr' instead of #array, because there is a module called array, and I may

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Steven D'Aprano
On Thu, Dec 11, 2014 at 02:25:53PM -0600, Galen Seilis wrote: > I would appreciate assitance understanding why this doesn't work, and how I > can get up-and-running with inputing JSON code into Python. Did you try reading the Fine Manual? It has many examples! For Python 2: https://docs.python.o

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Ben Finney
Alan Gauld writes: > On 11/12/14 23:15, Ben Finney wrote: > > >> *array = json.load( { "name": "Joe", "address": "111 Street" } )* > > > > You are passing a Python dict value to the function. JSON is a > > serialisation format, and the input to ‘json.load’ must be a text > > string. > > Nope, its

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Martin A. Brown
Hello there, To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, in File "C:\Python27\lib

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 23:15, Ben Finney wrote: *array = json.load( { "name": "Joe", "address": "111 Street" } )* You are passing a Python dict value to the function. JSON is a serialisation format, and the input to ‘json.load’ must be a text string. Nope, its a file-like object. The input to loads()

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 20:25, Galen Seilis wrote: To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, i

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Ben Finney
Galen Seilis writes: > I am having difficulty interacting with JSON. The example below if a > typical input and output: Thank you for presenting a simple example and the resulting output. Unfortunately, your mail client has mangled it, inserting asterisks making syntax errors, and wrapping line

[Tutor] Parsing JSON with Python

2014-12-11 Thread Galen Seilis
To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, in File "C:\Python27\lib\json\__init__.py