After making a request to my django-rest-framework API, I receive the following item:
services = "['service1', 'service2', 'service3']"
I am aiming for
services = ['service1', 'service2', 'service3']
While working in JavaScript, I attempted to use JSON.parse(services)
- but it had no effect. I also gave $.parseJSON(services)
a try.
In my serializers, I experimented with setting services as ListField
, and also tried using JSONSerializerField()
class JSONSerializerField(serializers.Field):
# Referenced from http://stackoverflow.com/a/28200902
def to_internal_value(self, data):
return json.loads(data)
def to_representation(self, value):
return value