Hi Guys,
So I am trying to print the bus numbers in python. However when i go to access the dissabsembled name key it comes back with this error:
Traceback (most recent call last):
File "C:\Python27\curl test v2.0.py", line 13, in <module>
print(JSONData['stopEvents']['disassembledName'])
TypeError: list indices must be integers, not str
any help would be appreciated here is my code:
import requests, json
import os
url = 'https://api.transport.nsw.gov.au/v1/tp/departure_mon?outputFormat=rapidJSON&coordOutputFormat=EPSG%3A4326&mode=direct&type_dm=stop&name_dm=10137620&itdDate=20180110&itdTime=1235&departureMonitorMacro=true&TfNSWDM=true&version=10.2.1.42'
payload = ''
headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Authorization': 'apikey ' }
r = requests.get(url, data=payload, headers=headers)
print(r)
JSONData = json.loads(r.content)
print(JSONData['stopEvents']['disassembledName'])