Hi I have a following code:
def dah(o):
assert False
print simplejson.dumps(['string', None, 3, 0], default=dah)
The problem is that the code above should throw an exception - but it does not. It completely ignores my default class.
I have also tried to use this:
class NoneToEmptyStringEncoder(simplejson.JSONEncoder):
"""
Json encoder that replaces nulls with empty strings
"""
def default(self, o):
assert False
if o:
return super(NoneToEmptyStringEncoder, self).default(o)
else:
return super(NoneToEmptyStringEncoder, self).default('')
print simplejson.dumps(['string', None, 3, 0], cls=NoneToEmptyStringEncoder)
But again it does not throw AssertionError, it completely ignores my doing and works normally.
Am I missing here something?