synapse/http/servlet.py
def parse_json_object_from_request(request, allow_empty_body=False):
    """Parse a JSON object from the body of a twisted HTTP request.

    Args:
        request: the twisted HTTP request.
        allow_empty_body (bool): if True, an empty body will be accepted and
            turned into an empty dict.

    Raises:
        SynapseError if the request body couldn't be decoded as JSON or
            if it wasn't a JSON object.
    """
    content = parse_json_value_from_request(
        request, allow_empty_body=allow_empty_body,
    )

    if allow_empty_body and content is None:
        return {}

    if type(content) != dict:
        message = "Content must be a JSON object."
        raise SynapseError(400, message, errcode=Codes.BAD_JSON)

    return content
Parse a JSON object from the body of a twisted HTTP request.

    Args:
        request: the twisted HTTP request.
        allow_empty_body (bool): if True, an empty body will be accepted and
            turned into an empty dict.

    Raises:
        SynapseError if the request body couldn't be decoded as JSON or
            if it wasn't a JSON object.
    
Parse a JSON object from the body of a twisted HTTP request.
Args:
request: the twisted HTTP request.
allow_empty_body (bool): if True, an empty body will be accepted and
turned into an empty dict.

SynapseError if the request body couldn't be decoded as JSON or
if it wasn't a JSON object.
Parse a JSON object from the body of a twisted HTTP request . Args : request : the twisted HTTP request . allow_empty_body ( bool ) : if True an empty body will be accepted and turned into an empty dict . SynapseError if the request body couldn ' t be decoded as JSON or if it wasn ' t a JSON object .
def parse_json_object_from_request(request, allow_empty_body=False):
    content = parse_json_value_from_request(
        request, allow_empty_body=allow_empty_body,
    )
    if allow_empty_body and content is None:
        return {}
    if type(content) != dict:
        message = "Content must be a JSON object."
        raise SynapseError(400, message, errcode=Codes.BAD_JSON)
    return content
def parse_json_object_from_request ( request , allow_empty_body = False ) : content = parse_json_value_from_request ( request , allow_empty_body = allow_empty_body , ) if allow_empty_body and content is None : return { } if type ( content ) != dict : message = "Content must be a JSON object." raise SynapseError ( 400 , message , errcode = Codes . BAD_JSON ) return content
Parse a JSON object from the body of a twisted HTTP request.
Parse a JSON object from the body of a twisted HTTP request .
"""Parse a JSON object from the body of a twisted HTTP request.

    Args:
        request: the twisted HTTP request.
        allow_empty_body (bool): if True, an empty body will be accepted and
            turned into an empty dict.

    Raises:
        SynapseError if the request body couldn't be decoded as JSON or
            if it wasn't a JSON object.
    """
request
allow_empty_body