AnsweredAssumed Answered

How do I get this JSON into a pyhton list or dictionary?

Question asked by geonb_bernie on Apr 12, 2015
Latest reply on Apr 13, 2015 by geonb_bernie

Please help.  I'm new to Python.  I am writing my first python script.  I have made good progress but I am having trouble handling the response from a the ArcGIS Server 10.2 REST API 'project' operation. Here is some code that will get a sample response:

 

import urllib

import json

urlstring = 'http://geonb-t.snb.ca/arcgis/rest/services/Utilities/Geometry/GeometryServer/project?inSR=2219&outSR=2953&geometries=674728.283,5319788.292&transformation=1841&transformForward=TRUE&f=json'

ro1 = urllib.urlopen(urlstring)

ro2 = ro1.read()

print ro2

 

The response looks like this:

    {"geometries":[{"x":2488268.7116061845,"y":7667607.8963871095}]}

 

   The web service response looks like a Python dictionary but When I save it in variable 'ro2' I get a string.  How do I read this response into a Python list or dictionary?  I need to extract the 'x' and 'y' values.  I am working in Python 2.6.5.

 

Thanks for the help,

Bernie.

Outcomes