title: Expecting value: line 1 column 1 (char 0) using JSON from C to Python
body: <p>I have a a micro controller which is sending data over serial to a python program. However it crashes with the following when I run in terminal:</p>
  
  <pre><code>{"id" : 43 ,"light" : 0, "temperature" : 2778}
  Shutdown
  Expecting value: line 1 column 1 (char 0)
  </code></pre>
  
  <p>The C code where it sends over USART:</p>
  
  <pre><code>printf("{\"id\" : %u ,\"Light\" : %u, \"Temperature\" : %u}\n\r", counter++, lightVal, tempVal);
  </code></pre>
  
  <p>And My python code:</p>
  
  <pre><code>    s = serial.Serial(port = '/dev/tty.usbserial-DA005A79', baudrate = 115200) # Zigduino 
  
  def read_loop(self):
          try:
              t = 0
              output = ''
              print 'starting'
              while self.read_data:
                  time.sleep(0.05)
                  data = s.read();
                  if len(data) &gt; 0:
                      output += data
                      if (data[-1]=='\n'):
                          print output
                          values = simplejson.loads(output)       
                          t += 0.2
                          output = ''
          except Exception, e:
              print "Shutdown"
              print str(e)
              exit()
  </code></pre>
  
  <p>An example of what it prints if I connect through serial and print (values are fine):</p>
  
  <pre><code>{"id" : 2 ,"light" : 1, "temperature" : 2665}
  {"id" : 3 ,"light" : 0, "temperature" : 2665}
  {"id" : 4 ,"light" : 0, "temperature" : 2665}
  {"id" : 5 ,"light" : 0, "temperature" : 2665}
  {"id" : 6 ,"light" : 0, "temperature" : 2778}
  {"id" : 7 ,"light" : 0, "temperature" : 2778}
  {"id" : 8 ,"light" : 0, "temperature" : 2665}
  {"id" : 9 ,"light" : 0, "temperature" : 2665}
  </code></pre>
  
  <p>I have looked at <a href="https://stackoverflow.com/questions/16573332/jsondecodeerror-expecting-value-line-1-column-1-char-0">JSONDecodeError: Expecting value: line 1 column 1 (char 0)</a> and <a href="https://stackoverflow.com/questions/28820580/python-valueerror-expecting-value-line-1-column-1-char-0">Python - ValueError: Expecting value: line 1 column 1 (char 0)</a> but they haven't really helped. And judging the notation here: <a href="http://jsonformatter.curiousconcept.com" rel="nofollow noreferrer">http://jsonformatter.curiousconcept.com</a> it should be ok?</p>
  
  <p>EDIT: I have tried with and without the '\r' at the end.</p>