You are double encoding your JSON strings. data
is already a JSON string, and doesn’t need to be encoded again:
>>> import json
>>> not_encoded = {"created_at":"Fri Aug 08 11:04:40 +0000 2014"}
>>> encoded_data = json.dumps(not_encoded)
>>> print encoded_data
{"created_at": "Fri Aug 08 11:04:40 +0000 2014"}
>>> double_encode = json.dumps(encoded_data)
>>> print double_encode
"{\"created_at\": \"Fri Aug 08 11:04:40 +0000 2014\"}"
Just write these directly to your file:
with open('data{}.txt'.format(self.timestamp), 'a') as f:
f.write(data + '\n')