Change json.dumps to json.loads (#774)

`json.dumps` converts JSON to Python string which is not what's needed here. If `json.dumps` is used, `statuses[0]` becomes `"`.
This commit is contained in:
ujjwal123123 2020-06-20 17:31:35 +05:30 committed by GitHub
parent 56f3518b29
commit 0f8951c40d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -65,7 +65,7 @@ import requests
import json
response = requests.get("https://mastodon.example/api/v1/timelines/tag/cats?limit=2")
statuses = json.dumps(response.text) # this converts the json to a python list of dictionary
statuses = json.loads(response.text) # this converts the json to a python list of dictionary
assert statuses[0]["visibility"] == "public" # we are reading a public timeline
print(statuses[0]["content"]) # this prints the status text
```