Search code examples
apipostmanfalconframeworkfalcon

Falcon for building API


How do I obtain the req in falcon as json and not string as seperate key value pairs.

If {"a:213","b":32435} How do i make sure a is passed and then obtain value of a


Solution

  • I think following code will help you:

    json_data = json.loads(req.stream.read())
    

    OR if you want to specify specific encoding format of input data.

    json_data = json.loads(req.stream.read().decode('utf8'))
    

    Please let me know you need further clarification.