1try: 2 from uio import StringIO 3 import ujson as json 4except: 5 try: 6 from io import StringIO 7 import json 8 except ImportError: 9 print("SKIP") 10 raise SystemExit 11 12s = StringIO() 13json.dump(False, s) 14print(s.getvalue()) 15 16s = StringIO() 17json.dump({"a": (2, [3, None])}, s) 18print(s.getvalue()) 19 20# dump to a small-int not allowed 21try: 22 json.dump(123, 1) 23except (AttributeError, OSError): # CPython and uPy have different errors 24 print("Exception") 25 26# dump to an object not allowed 27try: 28 json.dump(123, {}) 29except (AttributeError, OSError): # CPython and uPy have different errors 30 print("Exception") 31