Package: ujson1
This is a compatibility fork of ultrajson 1.35 that is intended to coexist with
newer versions by renaming the c extension to “ujson1”.Development on mainline ultrajson 3.x has reumed inhttps://github.com/ultrajson/ultrajsonand please send pull requests there
unless they are absolutely necessary to get you OFF of 1.x.UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.For a more painless day to day C/C++ JSON decoder experience please checkoutujson4c, based on UltraJSON.Please checkout the rest of the projects in the Ultra series:http://github.com/esnme/ultramemcachehttp://github.com/esnme/ultramysqlTo install it just run Pip as usual:$ pip install ujsonUsageMay be used as a drop in replacement for most other JSON parsers for Python:>>> import ujson
>>> ujson.dumps([{"key": "value"}, 81, True])
'[{"key":"value"},81,true]'
>>> ujson.loads("""[{"key": "value"}, 81, true]""")
[{u'key': u'value'}, 81, True]Encoder optionsencode_html_charsUsed to enable special encoding of “unsafe” HTML characters into safer Unicode sequences. Default is false:>>> ujson.dumps("<script>John&Doe", encode_html_chars=True)
'"\\u003cscript\\u003eJohn\\u0026Doe"'ensure_asciiLimits output to ASCII and escapes all extended characters above 127. Default is true. If your end format supports UTF-8 setting this option to false is highly recommended to save space:>>> ujson.dumps(u"\xe5\xe4\xf6")
'"\\u00e5\\u00e4\\u00f6"'
>>> ujson.dumps(u"\xe5\xe4\xf6", ensure_ascii=False)
'"\xc3\xa5\xc3\xa4\xc3\xb6"'double_precisionControls how many decimals to encode for double or decimal values. Default is 9:>>> ujson.dumps(math.pi)
'3.1415926536'
>>> ujson.dumps(math.pi, double_precision=1)
'3.1'
>>> ujson.dumps(math.pi, double_precision=0)
'3'
>>> ujson.dumps(math.pi, double_precision=4)
'3.1416'escape_forward_slashesControls whether forward slashes (/) are escaped. Default is True:>>> ujson.dumps("http://esn.me")
'"http:\/\/esn.me"'
>>> ujson.dumps("http://esn.me", escape_forward_slashes=False)
'"http://esn.me"'indentControls whether indention (“pretty output”) is enabled. Default is 0 (disabled):>>> ujson.dumps({"foo": "bar"})
'{"foo":"bar"}'
>>> ujson.dumps({"foo": "bar"}, indent=4)
{
    "foo":"bar"
}Decoders optionsprecise_floatSet to enable usage of higher precision (strtod) function when decoding string to double values. Default is to use fast but less precise builtin functionality:>>> ujson.loads("4.56")
4.5600000000000005
>>> ujson.loads("4.56", precise_float=True)
4.5599999999999996Test machine:Linux 3.13.0-66-generic x86_64 #108-Ubuntu SMP Wed Oct 7 15:20:27 UTC 2015Versions:CPython 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]blist     : 1.3.6simplejson: 3.8.1ujson     : 1.34 (0c52200eb4e2d97e548a765d5f089858c41967b0)yajl      : 0.3.5ujsonyajlsimplejsonjsonArray with 256 doublesencode3508.195742.003232.383309.09decode25103.3711257.8311696.2611871.04Array with 256 UTF-8 stringsencode3189.712717.142006.382961.72decode1354.94630.54356.35344.05Array with 256 stringsencode18127.4712537.3912541.2320001.00decode23264.7012788.8525427.889352.36Medium complex objectencode10519.385021.293686.864643.47decode9676.535326.798515.773017.30Array with 256 True valuesencode105998.03102067.2844758.5160424.80decode163869.9678341.57110859.36115013.90Array with 256 dict{string, int} pairsencode13471.3212109.093876.408833.92decode16890.638946.0712218.553350.72Dict with 256 arrays with 256 dict{string, int} pairsencode50.2546.4513.8229.28decode33.2722.1027.9110.43Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keysencode27.197.752.39Complex objectencode577.98387.81470.02decode496.73234.44151.00145.16Versions:CPython 3.4.3 (default, Oct 14 2015, 20:28:29) [GCC 4.8.4]blist     : 1.3.6simplejson: 3.8.1ujson     : 1.34 (0c52200eb4e2d97e548a765d5f089858c41967b0)yajl      : 0.3.5ujsonyajlsimplejsonjsonArray with 256 doublesencode3477.155732.243016.763071.99decode23625.209731.459501.579901.92Array with 256 UTF-8 stringsencode1995.892151.611771.981817.20decode1425.04625.38327.14305.95Array with 256 stringsencode25461.7512188.6413054.7614429.81decode21981.3117014.2223869.4822483.58Medium complex objectencode10821.464837.043114.044254.46decode7887.775126.674934.606204.97Array with 256 True valuesencode100452.8694639.4246657.6360358.63decode148312.6975485.9088434.91116395.51Array with 256 dict{string, int} pairsencode11698.138886.963043.696302.35decode10686.407061.775646.807702.29Dict with 256 arrays with 256 dict{string, int} pairsencode44.2634.4310.4021.97decode28.4623.9518.7022.83Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keysencode33.606.9422.34Complex objectencode432.30351.47379.34decode434.40221.97149.57147.79