Sorry Norm, I really don’t understand your point
json is part of Python’s standard library and you always have to import the modules you use.
.
Imo this is the kind of task that dynamic languages make easy. Arrays, objects, arrays of objects, objects containing arrays, whatever…
Here’s an example of some quite complex JSON returned by the Betfair API:
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"marketId": "1.113197547",
"marketName": "FC Betlemi Keda +1",
"marketStartTime": "2014-03-13T11:00:00.000Z",
"totalMatched": 12,
"runners": [
{
"selectionId": 6843871,
"runnerName": "FC Betlemi Keda +1",
"handicap": 0,
"sortPriority": 1,
"metadata": {
"runnerId": "63123618"
}
},
{
"selectionId": 6830600,
"runnerName": "FC Samtredia -1",
"handicap": 0,
"sortPriority": 2,
"metadata": {
"runnerId": "63123619"
}
},
{
"selectionId": 151478,
"runnerName": "Draw",
"handicap": 0,
"sortPriority": 3,
"metadata": {
"runnerId": "63123620"
}
}
],
"eventType": {
"id": "1",
"name": "Soccer"
},
"competition": {
"id": "2356065",
"name": "Pirveli Liga"
},
"event": {
"id": "27165685",
"name": "FC Samtredia v FC Betlemi Keda",
"countryCode": "GE",
"timezone": "GMT",
"openDate": "2014-03-13T11:00:00.000Z"
}
}
]
}
And this shows how easy it is to pick out a deeply nested detail using Python:
import json
js = json.loads(jsonData) # jsonData being the above as a string
print(js["result"][0]["runners"][0]["runnerName"])
# FC Betlemi Keda +1