I am creating a dashboard for Google Analytics and I want to convert the JSON what is coming from Google Analytics into a python list, but keep getting this error:
Expecting property name: line 1 column 2 (char 1)
Here is the code which should convert it:
results = get_results(service, profile)
data = json.loads(str(results))
return data
Results is equal to:
{u'columnHeaders': [{u'columnType': u'METRIC',
u'dataType': u'INTEGER',
u'name': u'ga:sessions'}],
u'containsSampledData': False,
u'id': u'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:xxxxxxxx&metrics=ga:sessions&start-date=7daysAgo&end-date=today',
u'itemsPerPage': 1000,
u'kind': u'analytics#gaData',
u'profileInfo': {u'accountId': u'xxxxxxxx',
u'internalWebPropertyId': u'xxxxxxxx',
u'profileId': u'xxxxxxxx',
u'profileName': u'xxxxxxxx',
u'tableId': u'ga:xxxxxxxx',
u'webPropertyId': u'UA-xxxxxxxx-1'},
u'query': {u'end-date': u'today',
u'ids': u'ga:xxxxxxxx',
u'max-results': 1000,
u'metrics': [u'ga:sessions'],
u'start-date': u'7daysAgo',
u'start-index': 1},
u'rows': [[u'109826']],
u'selfLink': u'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:76270671&metrics=ga:sessions&start-date=7daysAgo&end-date=today',
u'totalResults': 1,
u'totalsForAllResults': {u'ga:sessions': u'109826'}}
I have removed some account details above but hopefully get the picture.
Thanks,
Aaron
resultsmight already be a dictresults(doprint(type(results)))?