Python 3 compatibility when json-encoding regexes, PYTHON-602.
Note that we can't preserve key order in json_util.dumps in Python 2.4, PYTHON-602.