def convert_resource(self, resource, view):
        serializer_data = view.get_serializer(instance=None)
        fields = serializer_data.fields

        links = {}

        if "links" in resource:
            links = resource["links"]

            del resource["links"]

        for field_name, field in six.iteritems(fields):
            if field_name not in links:
                continue

            related_field = get_related_field(field)

            if isinstance(related_field, relations.HyperlinkedRelatedField):
                if is_related_many(field):
                    pks = links[field_name]
                    model = related_field.queryset.model

                    resource[field_name] = []

                    for pk in pks:
                        obj = model(pk=pk)

                        try:
                            url = related_field.to_representation(obj)
                        except __HOLE__:
                            url = related_field.to_native(obj)

                        resource[field_name].append(url)
                else:
                    pk = links[field_name]
                    model = related_field.queryset.model

                    obj = model(pk=pk)

                    try:
                        url = related_field.to_representation(obj)
                    except AttributeError:
                        url = related_field.to_native(obj)

                    resource[field_name] = url
            else:
                resource[field_name] = links[field_name]

        return resource
dataset/ETHPy150Open kevin-brown/drf-json-api/rest_framework_json_api/parsers.py/JsonApiMixin.convert_resource