Python: "import JSON... json.loads(request.body)" 2.7->3.4
Question: I recently converted a django server to python version 3.4.1 from python
version 2.7. My request.body is an array serialized to JSON. When de-
serialized it will be a python list.

Unfortunately, it would seem that json.loads no longer takes raw bytes (which
is what request.body is).

How can I fix this issue?

    
    
    def index(request):
        if request.method == 'POST':
    
            print("Made it here!")
            registered = []
            notRegistered = []
            print("Is it this?")
    
            print(repr(request.body))
    
            data = json.loads(request.body)
    
            print("Did I make it here?")
    

The last call to print never executes, which is why I'm assuming it has to do
with json.loads()


Answer: I would expect a traceback to occur rather than just "the last line never
executing", but that aside...

    
    
    # Let's just assume the request is UTF-8 encoded.
    data = json.loads(request.body.decode('utf-8'))
    

