def test_compound_types(self): self.assertEqual('[1,2,[true,false]]', json.to_json([1, 2, [True, False]])) self.assertEqual( '{"one":1,"other":[null,0],"two":2}', json.to_json({ "one": 1, "two": 2, "other": [None, 0] }))
def test_simple_types(self): self.assertEqual('42', json.to_json(42)) self.assertEqual('123.456', json.to_json(123.456)) self.assertEqual('true', json.to_json(True)) self.assertEqual('false', json.to_json(False)) self.assertEqual('null', json.to_json(None)) self.assertEqual('"String"', json.to_json('String')) self.assertEqual(r'"a \" quote"', json.to_json('a " quote'))
def test_compound_types(self): self.assertEqual('[1,2,[true,false]]', json.to_json([1, 2, [True, False]])) self.assertEqual('{"one":1,"other":[null,0],"two":2}', json.to_json({"one": 1, "two": 2, "other": [None, 0]}))