def serialize_as_dict(self, obj, type=None): if isinstance(obj, Base): return obj.as_json_dict() elif isinstance(obj, dict): ret = {to_camel_case(k): self.serialize_as_dict(v) for k, v in obj.items()} if type is not None: ret['type'] = type return ret elif isinstance(obj, list): return [self.serialize_as_dict(elem) for elem in obj] else: if PY3: self.assertIsInstance(obj, (str, bool, Number)) else: self.assertIsInstance(obj, (basestring, bool, Number)) # noqa return obj
def test_to_camel_case(self): self.assertEqual(to_camel_case('hoge_bar'), 'hogeBar')
def test_to_camel_case(self): self.assertEqual(to_camel_case('hoge_bar'), 'hogeBar') self.assertEqual(to_camel_case('unique_media_played_100_percent'), 'uniqueMediaPlayed100Percent')