def load_request_data(request_schema, partial=False):
    """
    Load request data as JSON using the given schema.

    Forces JSON decoding even if the client not specify the `Content-Type` header properly.

    This is friendlier to client and test software, even at the cost of not distinguishing
    HTTP 400 and 415 errors.

    """
    try:
        json_data = request.get_json(force=True) or {}
    except Exception:
        # if `simplpejson` is installed, simplejson.scanner.JSONDecodeError will be raised
        # on malformed JSON, where as built-in `json` returns None
        json_data = {}
    request_data = request_schema.load(json_data, partial=partial)
    if request_data.errors:
        # pass the validation errors back in the context
        raise with_context(
            UnprocessableEntity("Validation error"), [{
                "message": "Could not validate field: {}".format(field),
                "field": field,
                "reasons": reasons
            } for field, reasons in request_data.errors.items()],
        )
    return request_data.data
Load request data as JSON using the given schema.

    Forces JSON decoding even if the client not specify the `Content-Type` header properly.

    This is friendlier to client and test software, even at the cost of not distinguishing
    HTTP 400 and 415 errors.