def default(self, obj): if type(obj) in self.addedtypes: return self.addedtypes[type(obj)].encode(obj) return json.JSONEncoder.default(self, obj)