title: Read JSON formatted string in Python
body: <p>I have a simple Websockets server in python, it receives messages from Android app clients, I tried to make the message payload from the client in JSON but I felt. It is only working when it is in String.
  One solution I found is to keep the message string but with JSON format:</p>
  
  <pre class="lang-js prettyprint-override"><code>try {
      json.put("name", "Jack");
      json.put("age", "24");
      message = json.toString(2);
  } catch (JSONException e) {
      e.printStackTrace();
  }
  
  webSocket.send(message);
  </code></pre>
  
  <p>Inspired by the Javascript <code>JSON.stringify(message)</code></p>
  
  <p>I printed the message on the server and it seems to be formatted</p>
  
  <p><a href="https://i.stack.imgur.com/BQKkK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BQKkK.png" alt="enter image description here"></a></p>
  
  <p>My question is how can I reverse back it into JSON on the server when it received?</p>
  
  <p>I tried this way in Python:</p>
  
  <pre><code>def on_message(self,message):
      data = json.loads(message)
      self.write_message(data['name'])
  </code></pre>
  
  <p>but I got this error:</p>
  
  <pre><code>ERROR:tornado.application:Uncaught exception in /
  Traceback (most recent call last):
    File "/usr/local/lib/python3.4/dist-packages/tornado/websocket.py", line 494, in _run_callback
      result = callback(*args, **kwargs)
    File "index.py", line 24, in on_message
      data = json.loads(message)
    File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
      return _default_decoder.decode(s)
    File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
      raise ValueError(errmsg("Expecting value", s, err.value)) from None
  ValueError: Expecting value: line 1 column 1 (char 0)
  </code></pre>