Falcon parsing json error
<p>I'm trying out Falcon for a small api project. Unfortunate i'm stuck on the json parsing stuff and code from the documentation examples does not work.</p>

<p>I have tried so many things i've found on Stack and Google but no changes.
I've tried the following codes that results in the errors below</p>

<pre><code>import json
import falcon

class JSON_Middleware(object):
    def process_request(self, req, resp):
       raw_json = json.loads(req.stream.read().decode('UTF-8'))
       """Exception: AttributeError: 'str' object has no attribute 'read'"""

       raw_json = json.loads(req.stream.read(), 'UTF-8')
       """Exception: TypeError: the JSON object must be str, not 'bytes'"""

       raw_json = json.loads(req.stream, 'UTF-8')
       """TypeError: the JSON object must be str, not 'Body'"""
</code></pre>

<p>I'm on the way of giving up, but if somebody can tell me why this is happening and how to parse JSON in Falcon i would be extremely thankful.</p>

<p>Thanks</p>

<p>Environment:
OSX Sierra
Python 3.5.2
Falcon and other is the latest version from Pip</p>

<p>your code should work if other pieces of code are in place . a quick test(filename app.py):</p>

<pre><code>import falcon
import json

class JSON_Middleware(object):
    def process_request(self, req, resp):
       raw_json = json.loads(req.stream.read())
       print raw_json

class Test:
    def on_post(self,req,resp):
        pass

app = application = falcon.API(middleware=JSON_Middleware())
t = Test()
app.add_route('/test',t)
</code></pre>

<p>run with: <code>gunicorn app</code><br>
<code>$ curl -XPOST 'localhost:8000' -d '{"Hello":"wold"}'</code></p>

python python-3.x falconframework