def METHOD_NAME(self, result, parser_context):
    """
    Formats the output of calling JSONParser to match the JSON:API specification
    and returns the result.
    """
    if not isinstance(result, dict) or "data" not in result:
        raise ParseError("Received document does not contain primary data")
    data = result.get("data")
    parser_context = parser_context or {}
    view = parser_context.get("view")
    from rest_framework_json_api.views import RelationshipView
    if isinstance(view, RelationshipView):
        # We skip parsing the object as JSON:API Resource Identifier Object and not
        # a regular Resource Object
        if isinstance(data, list):
            for resource_identifier_object in data:
                if not (
                    resource_identifier_object.get("id")
                    and resource_identifier_object.get("type")
                ):
                    raise ParseError(
                        "Received data contains one or more malformed JSON:API "
                        "Resource Identifier Object(s)"
                    )
        elif not (data.get("id") and data.get("type")):
            raise ParseError(
                "Received data is not a valid JSON:API Resource Identifier Object"
            )
        return data
    request = parser_context.get("request")
    method = request and request.method
    # Sanity check
    if not isinstance(data, dict):
        raise ParseError(
            "Received data is not a valid JSON:API Resource Identifier Object"
        )
    # Check for inconsistencies
    if method in ("PUT", "POST", "PATCH"):
        resource_name = get_resource_name(
            parser_context, expand_polymorphic_types=True
        )
        if isinstance(resource_name, str):
            if data.get("type") != resource_name:
                raise exceptions.Conflict(
                    "The resource object's type ({data_type}) is not the type that "
                    "constitute the collection represented by the endpoint "
                    "({resource_type}).".format(
                        data_type=data.get("type"), resource_type=resource_name
                    )
                )
        else:
            if data.get("type") not in resource_name:
                raise exceptions.Conflict(
                    "The resource object's type ({data_type}) is not the type that "
                    "constitute the collection represented by the endpoint "
                    "(one of [{resource_types}]).".format(
                        data_type=data.get("type"),
                        resource_types=", ".join(resource_name),
                    )
                )
    if not data.get("id") and method in ("PATCH", "PUT"):
        raise ParseError(
            "The resource identifier object must contain an 'id' member"
        )
    if method in ("PATCH", "PUT"):
        lookup_url_kwarg = getattr(view, "lookup_url_kwarg", None) or getattr(
            view, "lookup_field", None
        )
        if lookup_url_kwarg and str(data.get("id")) != str(
            view.kwargs[lookup_url_kwarg]
        ):
            raise exceptions.Conflict(
                "The resource object's id ({data_id}) does not match url's "
                "lookup id ({url_id})".format(
                    data_id=data.get("id"), url_id=view.kwargs[lookup_url_kwarg]
                )
            )
    # Construct the return data
    parsed_data = {"id": data.get("id")} if "id" in data else {}
    parsed_data["type"] = data.get("type")
    parsed_data.update(self.parse_attributes(data))
    parsed_data.update(self.parse_relationships(data))
    parsed_data.update(self.parse_metadata(result))
    return parsed_data