Error in parsing the json and formatting to pretty json
<p>I have used requests module and now i got the data back in json format and by taking help from this <a href="https://stackoverflow.com/a/12944035/5908241">How to Python prettyprint a JSON file</a> i have written my code and while executing the code it gave me an errro <code>Expected a string or buffer</code>, so i have changed the variable passed to the parser to string. Now it again gave another error.</p>

<pre><code>#Import
import requests
import json

r = requests.post('http://httpbin.org/post', data = {'key':'value'})
print(r.status_code)
got_data_in_json = r.json()
parsed_json = json.loads(str(got_data_in_json))
print(json.dumps(parsed_json, indent=4 ,sort_keys=True))
</code></pre>

<p>Error Log:</p>

<pre><code>python requests_post.py
200
Traceback (most recent call last):
  File "requests_post.py", line 8, in &lt;module&gt;
    parsed_json = json.loads(str(got_data_in_json))
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 2 (char 1)
</code></pre>

<p>Any solutions to this problem?</p>