mod-wsgi get an error when trying to convert string params to json
Question: I get the following error:

    
    
    File "C:\\Python34\\Lib\\json\\decoder.py", line 361, in raw_decode\r
    raise ValueError(errmsg("Expecting value", s, err.value)) from None\r
    ValueError: Expecting value: line 1 column 1 (char 0)\r, referer
    

when I send with xmlhttp the following params:

    
    
    xmlhttp.send( "{ \"field1\": 'hello', \"field2\" : 'hello2'}" ); 
    

mod_wsgi code:

    
    
    def application(environ, start_response):
    
        output = ChildClass().getValue()
        print( output)
        request_body_size = int(environ['CONTENT_LENGTH'])
        request_body = environ['wsgi.input'].read(request_body_size)
        status = '200 OK'
        strBody = str(request_body)
        jsnBody = json.loads(strBody )
        stroutput = '@' + strBody 
        for iterating_var in output:
    
            values = ','.join(str(v) for v in iterating_var)
            #str = ''.join(output[0])
            print('second  ' + values)
            stroutput +=  '&&' + values
            #print(str.encode('UTF-8'))
    
        response_headers = [('Content-type', 'text/plain'),
                            ('Content-Length', str(len(stroutput)))]
        start_response(status, response_headers)
        return [stroutput.encode('UTF-8')]
    

The problematic lines:

    
    
    strBody = str(request_body)
     jsnBody = json.loads(strBody )
    


Answer: Python's json decoder raises that cryptic error when mixed quotes are used in
the string to be loaded.

    
    
    import json
    json.loads('{"thing": "value"}')
    json.loads('{\'thing\': \'value\'}') #json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
    json.loads('{"thing": \'value\'}') # json.decoder.JSONDecodeError: Expecting value: line 1 column 11 (char 10)is formatted with
    json.loads("{\"thing\": 'value'}") # json.decoder.JSONDecodeError: Expecting value: line 1 column 11 (char 10)
    

Using `"` instead of `'` for strings in your json should resolve your error.

