title: python websockets; parse json
body: <p>I have this script using <code>websockets</code> </p>
  
  <pre><code>import asyncio
  import websockets
  import json
  
  async def echo(websocket, path):
      async for message in websocket:
          print(message)
          await websocket.send(message)
  
  asyncio.get_event_loop().run_until_complete(
      websockets.serve(echo, 'localhost', 8765))
  asyncio.get_event_loop().run_forever()
  </code></pre>
  
  <p>I send data from javascript that's in json format</p>
  
  <pre><code>var socket = new WebSocket('ws://localhost:8765');
  socket.send(temp1);
  temp1
  &gt; {img_width: 600, img_height: 399, areas: Array(1)}
  </code></pre>
  
  <p>this is what's printed back by python</p>
  
  <pre><code>(pixelart) sam@sam-Lenovo-G51-35:~/code/pixelart$ python path.py
  [object Object]
  </code></pre>
  
  <p>I've tried to check for ways of accessing it's attributes to see if I can get to the data using <code>print(dir(message))</code> this is what I got back</p>
  
  <pre><code>['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower','isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
  </code></pre>
  
  <p>looks more like binders for a string so I tried to check it's type <code>print(type(message))</code></p>
  
  <pre><code>(pixelart) sam@sam-Lenovo-G51-35:~/code/pixelart$ python path.py
  &lt;class 'str'&gt;
  </code></pre>
  
  <p>it looks like it converts the object into a string.</p>