circuitpython/tests/extmod/ujson_dumps_ordereddict.py
Andrew Leech 1e87f11d3f py/objdict: Support ujson.dump() of OrderedDict objects.
Following CPython, OrderedDict are dumped with the syntax of dict.
2019-11-13 13:51:18 +11:00

13 lines
285 B
Python

try:
import ujson as json
from ucollections import OrderedDict
except ImportError:
try:
import json
from collections import OrderedDict
except ImportError:
print("SKIP")
raise SystemExit
print(json.dumps(OrderedDict(((1, 2), (3, 4)))))