json.dumps()
returns the JSON string representation of the python dict. See the docs
You can't do r['rating']
because r is a string, not a dict anymore
Perhaps you meant something like
r = {'is_claimed': 'True', 'rating': 3.5}
json = json.dumps(r) # note i gave it a different name
file.write(str(r['rating']))