title: Python: Handling newlines in json.load() vs json.loads()
body: <p>According to <a href="https://stackoverflow.com/a/9295597/2066468">this answer</a>, newlines in a JSON string should always be escaped. This does not appear to be necessary when I load the JSON with <code>json.load()</code>.</p>
  
  <p>I've saved the following string to file:</p>
  
  <pre><code>{'text': 'Hello,\n How are you?'}
  </code></pre>
  
  <p>Loading the JSON with <code>json.load()</code> does not throw an exception, even though the <code>\n</code> is not escaped:</p>
  
  <pre><code>&gt;&gt;&gt; with open('test.json', 'r') as f:
  ...   json.load(f)
  ...
  {'text': 'Hello,\n How are you?'}
  </code></pre>
  
  <p>However, if I use <code>json.loads()</code>, I get an exception:</p>
  
  <pre><code>&gt;&gt;&gt; s
  '{"text": "Hello,\n How are you?"}'
  &gt;&gt;&gt; json.loads(s)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "c:\Python34\lib\json\__init__.py", line 318, in loads
      return _default_decoder.decode(s)
    File "c:\Python34\lib\json\decoder.py", line 343, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "c:\Python34\lib\json\decoder.py", line 359, in raw_decode
      obj, end = self.scan_once(s, idx)
  ValueError: Invalid control character at: line 1 column 17 (char 16)
  </code></pre>
  
  <p>My questions:</p>
  
  <ol>
  <li>Does <code>json.load()</code> automatically escape <code>\n</code> inside the file object?</li>
  <li>Should one always do <code>\\n</code> regardless of whether the JSON will be read by <code>json.load()</code> or <code>json.loads()</code>?</li>
  </ol>