title: Python JSON decode ValueError: Extra data:
body: <p>I'm having a problem trying to decode and print JSON I receive from a socket connection.</p>
  
  <p>The full traceback:</p>
  
  <pre><code>C:\Users\Jeremy&gt;python F:\Files\Python\test.py
  2013-01-04 21:15:35 [INFO] [AutoSaveWorld] World save Complete!
  2013-01-04 21:15:50 [INFO] [←[34;1mMain←[37;1m]←[32;22mRexOZ←[37;1m: you cahaned
   your house it looks awesome←[m
  Traceback (most recent call last):
    File "F:\Files\Its safer indoors\Python\test.py", line 14, in &lt;module&gt;
      data = json.loads(dreceve)
    File "C:\Python33\lib\json\__init__.py", line 309, in loads
      return _default_decoder.decode(s)
    File "C:\Python33\lib\json\decoder.py", line 355, in decode
      raise ValueError(errmsg("Extra data", s, end, len(s)))
  ValueError: Extra data: line 2 column 1 - line 3 column 1 (char 151 - 344)
  </code></pre>
  
  <p>As you can see the first 2 lines print fine and then it crashes.</p>
  
  <p>Full code:</p>
  
  <pre><code>import socket
  import json
  import re
  
  HOST = 'host.host.net'
  PORT = 8082
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect((HOST, PORT))
  dsend = "/api/subscribe?source=console&amp;key=SUPERSEXYSECRETEY&amp;show_previous=true\n"
  s.sendall(dsend.encode())
  
  while 1:
      dreceve = s.recv(1024).decode()
      data = json.loads(dreceve)
      succses = data['success']
      line = succses['line']
      print(line)
  
  s.close()
  </code></pre>
  
  <p>I have goggled around for this error and the pages I found did not solve my problem, any help work be appreciated.</p>