title: Issue parsing multiline JSON file using Python
body: <p>I am trying to parse a JSON multiline file using <code>json</code> library in Python 2.7. A simplified sample file is given below:</p>
  
  <pre><code>{
  "observations": {
      "notice": [
          {
              "copyright": "Copyright Commonwealth of Australia 2015, Bureau of Meteorology. For more information see: http://www.bom.gov.au/other/copyright.shtml http://www.bom.gov.au/other/disclaimer.shtml",
              "copyright_url": "http://www.bom.gov.au/other/copyright.shtml",
              "disclaimer_url": "http://www.bom.gov.au/other/disclaimer.shtml",
              "feedback_url": "http://www.bom.gov.au/other/feedback"
          }
      ]
  }
  }
  </code></pre>
  
  <p>My code is as follows:</p>
  
  <pre><code>import json
  
  with open('test.json', 'r') as jsonFile:
      for jf in jsonFile:
          jf = jf.replace('\n', '')
          jf = jf.strip()
          weatherData = json.loads(jf)
          print weatherData
  </code></pre>
  
  <p>Nevertheless, I get an error as shown below:</p>
  
  <pre><code>Traceback (most recent call last):
  File "test.py", line 8, in &lt;module&gt;
  weatherData = json.loads(jf)
  File "/home/usr/anaconda2/lib/python2.7/json/__init__.py", line 339, in loads
  return _default_decoder.decode(s)
  File "/home/usr/anaconda2/lib/python2.7/json/decoder.py", line 364, in decode
  obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/usr/anaconda2/lib/python2.7/json/decoder.py", line 380, in raw_decode
  obj, end = self.scan_once(s, idx)
  ValueError: Expecting object: line 1 column 1 (char 0)
  </code></pre>
  
  <p>Just to do some testing, I modified the code such that after removing newlines and striping away the leading and trailing white spaces, I write the contents to another file (with the <code>json</code> extension). Surprisingly, when I read back the latter file, I do not get any error and the parsing is successful. The modified code is as follows:</p>
  
  <pre><code>import json
  
  filewrite = open('out.json', 'w+')
  
  with open('test.json', 'r') as jsonFile:
      for jf in jsonFile:
          jf = jf.replace('\n', '')
          jf = jf.strip()
          filewrite.write(jf)
  
  filewrite.close()
  
  with open('out.json', 'r') as newJsonFile:
      for line in newJsonFile:
          weatherData = json.loads(line)
          print weatherData
  </code></pre>
  
  <p>The output is as follows:</p>
  
  <pre><code>{u'observations': {u'notice': [{u'copyright_url': u'http://www.bom.gov.au/other/copyright.shtml', u'disclaimer_url': u'http://www.bom.gov.au/other/disclaimer.shtml', u'copyright': u'Copyright Commonwealth of Australia 2015, Bureau of Meteorology. For more information see: http://www.bom.gov.au/other/copyright.shtml http://www.bom.gov.au/other/disclaimer.shtml', u'feedback_url': u'http://www.bom.gov.au/other/feedback'}]}}
  </code></pre>
  
  <p>Any idea what might be going on when new lines and white spaces are stripped before using <code>json</code> library?</p>