Does python support random json serialization? I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "commands.py", line 36, in toJson
return json.dumps(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 201, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 264, in iterencode
return _iterencode(o, 0)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 178, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <commands.SampleCommand object at 0x105d957d0> is not JSON serializable
Snippet:
class SampleCommand(Command):
def __init__(self,message=None):
super(Command, self).__init__()
pass
def parse(self):
pass
def toJson(self):
return json.dumps(self)