diff --git a/tests/test_xmljson.py b/tests/test_xmljson.py index 59bc608..fc1d20a 100644 --- a/tests/test_xmljson.py +++ b/tests/test_xmljson.py @@ -362,6 +362,7 @@ def test_etree(self): ('x', 'a'), ('y', 'b') ]), 'a', 'b') + eq({'x': None}, '') # None becomes an empty string with self.assertRaises(Exception): eq({'x': {'@x': 1}}, '') diff --git a/xmljson/__init__.py b/xmljson/__init__.py index 27c6a9a..2fd5e66 100644 --- a/xmljson/__init__.py +++ b/xmljson/__init__.py @@ -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