I've been programming an application that pulls information from an online API, and I need some help with it.
I'm using requests, and my current code is as follows
myData = requests.get('theapiwebsitehere.com/thispartisworking')
myRealData = myData.json()
x = myRealData['data']['playerStatSummaries']['playerStatSummarySet']['maxRating']
print x
I then get this error
myRealData = myData.json()
TypeError: 'NoneType' object is not callable
I want to be able to get to the variable maxRating, and print it out, but I can't seem to do that.
Thanks for your help.
There is another module that developers can use for pretty print JSON data. Using simplejson module, you can use its simplejson. dumps() method and pass the json object and indent value as parameters. It works similar to that of json module but is not a built-in module of Python.
print(response. json()) should give the the data formatted as JSON for this response.
Getting a specific property from a JSON response object Instead, you select the exact property you want and pull that out through dot notation. The dot ( . ) after response (the name of the JSON payload, as defined arbitrarily in the jQuery AJAX function) is how you access the values you want from the JSON object.
Firstly is myData actually returning anything?
If it is then you can try the following rather than work with the .json() function
Import the Json package and use the Json loads function on the text.
import json
newdata = json.loads(myData.text())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With