diff --git a/src/polyfills/json/__init__.py b/src/polyfills/json/__init__.py index e968234..6f4f23f 100644 --- a/src/polyfills/json/__init__.py +++ b/src/polyfills/json/__init__.py @@ -108,7 +108,7 @@ def dumps( # ---> Handle JSON arrays - elif obj_type == type([]): + elif obj_type in [type([None,]), type((None,))]: obj_string_parts.append("[") for item in obj: if len(obj_string_parts) > 1: diff --git a/src/polyfills/json/tests/dumps/test_dumps.py b/src/polyfills/json/tests/dumps/test_dumps.py index 2155daa..bf43023 100644 --- a/src/polyfills/json/tests/dumps/test_dumps.py +++ b/src/polyfills/json/tests/dumps/test_dumps.py @@ -103,7 +103,14 @@ def test_empty(self): def test_simple(self): self.assertEqual( json.dumps(["", "test1", "", "test2", ""]), - '["", "test1", "", "test2", ""]' + '["", "test1", "", "test2", ""]', + "List should be converted to JSON array" + ) + + self.assertEqual( + json.dumps(("", "test1", "", "test2", "")), + '["", "test1", "", "test2", ""]', + "Tuple should be converted to JSON array" )