def test_json(): d = Dictionary({ '/Boolean': True, '/Integer': 42, '/Real': Decimal('42.42'), '/String': String('hi'), '/Array': Array([1, 2, 3.14]), '/Dictionary': Dictionary({'/Color': 'Red'}), }) json_bytes = d.to_json(False) as_dict = json.loads(json_bytes) assert as_dict == { "/Array": [1, 2, 3.14], "/Boolean": True, "/Dictionary": { "/Color": "Red" }, "/Integer": 42, "/Real": 42.42, "/String": "hi", }
def test_json(): d = Dictionary({ '/Boolean': True, '/Integer': 42, '/Real': Decimal('42.42'), '/String': String('hi'), '/Array': Array([1, 2, 3.14]), '/Dictionary': Dictionary({'/Color': 'Red'}), }) json_bytes = d.to_json(False) try: as_dict = json.loads(json_bytes) except TypeError: as_dict = json.loads(json_bytes.decode('utf-8')) # Py3.5 shim assert as_dict == { "/Array": [1, 2, 3.140000], "/Boolean": True, "/Dictionary": { "/Color": "Red" }, "/Integer": 42, "/Real": 42.42, "/String": "hi", }