Skip to content

Commit

Permalink
Null elements translate to empty strings in Parker
Browse files Browse the repository at this point in the history
  • Loading branch information
sanand0 committed Nov 21, 2018
1 parent e910f4d commit 824e39b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/test_xmljson.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def test_etree(self):
('x', 'a'),
('y', 'b')
]), '<x>a</x>', '<y>b</y>')
eq({'x': None}, '<x/>') # None becomes an empty string
with self.assertRaises(Exception):
eq({'x': {'@x': 1}}, '<x x="1"/>')

Expand Down
2 changes: 2 additions & 0 deletions xmljson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def _tostring(value):
value = 'true'
elif value is False:
value = 'false'
elif value is None:
value = ''
return unicode(value) # noqa: convert to whatever native unicode repr

@staticmethod
Expand Down

0 comments on commit 824e39b

Please sign in to comment.