I have JavaScript that parses a JSON object (object has array) and returns the value from the ZONE
field.
var obj = JSON.parse(json_text);
parsed_val = obj.features[0].attributes.ZONE
I would like to convert the JavaScript code to Jython.
This is what I've tried:
from com.ibm.json.java import JSONObject
obj = JSONObject.parse(json_text)
parsed_val = obj.get('features.attributes.ZONE');
The Jython compiles, but it doesn't return a valid value (it returns None
). I think this is because I haven't referenced the array properly.
How can I parse the JSON object/array using Jython to get the ZONE value?
(Jython version is 2.7.0. However, I can't seem to use Python's JSON library (normally included in Jython)).