Is there a way to serialize a python class without using a custom encoder? I've tried the following approach but I get the error: TypeError: hello is not JSON serializable which is strange since "hello" is a string.
class MyObj(object):
def __init__(self, address):
self.address = address
def __repr__(self):
return self.address
x = MyObj("hello")
print json.dumps(x)
The output should be simply
"hello"