def assertBackAndForth(self, obj): """ Checks that conversion to json and back is idempotent. """ jsonable = thrift2json(obj) back = jsonable2thrift(jsonable, type(obj)) self.assertEquals(obj, back)
def value_to_string(self, obj): """ Used by XML serialization. """ return json.dumps(thrift_util.thrift2json(self._get_val_from_obj(obj)))
def get_db_prep_save(self, value, *args, **kwargs): if value is None: return None jsonable = thrift_util.thrift2json(value) return json.dumps(jsonable)
def get_db_prep_save(self, value): if value is None: return None jsonable = thrift_util.thrift2json(value) json = simplejson.dumps(jsonable) return json