We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 40be69d commit b50aa17Copy full SHA for b50aa17
embedly/models.py
@@ -22,3 +22,9 @@ def __str__(self):
22
23
def __unicode__(self):
24
return '<%s %s>' % (self.method.title(), self.original_url or "")
25
+
26
+ def __getitem__(self, key):
27
+ if (key in self.data) and (self.data[key] == None):
28
+ return ''
29
+ else:
30
+ return self.data[key]
embedly/tests.py
@@ -61,7 +61,13 @@ def test_model(self):
61
self.assertEqual(obj['new_key'], 'dict value')
62
63
def test_model_data_can_serialize(self):
64
- obj = Url({'a': {'key': 'value'}})
+ obj = Url({'hash': {'key': 'value'},
65
+ 'none': None,
66
+ 'empty': '',
67
+ 'float': 1.234,
68
+ 'int': 1,
69
+ 'string': 'string',
70
+ 'array': [0, -1]})
71
unserialzed = json.loads(json.dumps(obj.data))
72
self.assertDictEqual(obj.data, unserialzed)
73
0 commit comments