'Serializes model data into JSON-compatible types.'

def serialize_data(self, instance):

    if (self.fields is not None):
        if ((self.fields == '__all__') or (list(self.fields) == ['__all__'])):
            fields = None
        else:
            fields = self.fields
    else:
        fields = [f.name for f in instance._meta.get_fields() if (f.name not in self.exclude)]
    data = serializers.serialize('json', [instance], fields=fields)
    return json.loads(data)[0]['fields']
