[Answer]-Remove \" characters while returning json

1👍

You are serializing the object into jsonObject, but you return the original object. Just fix that and everything should work as expected.

Update:

Just change your code like this:

jsonObject = serializers.serialize('json', object, fields=('value', 'record_time'))
return HttpResponse(jsonObject, mimetype="application/json")

The change is the jsonObject in the second line.

👤Achim

0👍

Where you’re going wrong is confusing the printed representation of a JSON string with the actual string itself. Those slashes are just the console showing that the double-quotes inside the string are not ending the string, but are part of it. In other words, your JSON is just fine.

Leave a comment