I get this error message in Python/Django: bytearray(b'') is not JSON serializable. Currently, I do it like this:
...
from django.core.serializers.json import DjangoJSONEncoder
...
output = json.dumps(data, cls=DjangoJSONEncoder)
return HttpResponse(output)
I import DjangoJSONEncoder, because before that I had problem with datetime. That problem went away, but now I have another problem with type bytearray. So, I'm interested to know, if there is a standard and universal way of creating json string, no matter what data types you use.