Skip to content

aarki/strrapidjson

 
 

Repository files navigation

strrapidjson

About

strrapidjson is a fork of the pyrapidjson library (version 0.5.1), which in turn is a Python 2.7+ wrapper for rapidjson. For Python 3+ python-rapidjson is another alternative.

Main design goal of this library is to avoid using unicode() conversions in Python 2, sticking to (usually UTF8-encoded) str() instead.

  • When decoding, library always creates str() objects
  • When encoding, ensure_ascii=False is applied by default

There are performance advantages to avoiding conversion to unicode() objects when that is not needed.

Performance-wise, strrapidjson is faster than the standard library json module and comparable to ujson and simplejson packages.

Installation

from pip:

$ pip install strrapidjson

from pip+Github:

$ pip install git+https://github.com/aarki/strrapidjson

clone and run locally (rexcursive to pull rapidjson submodule):

$ git clone --recursive https://github.com/aarki/strrapidjson.git
$ cd strrapidjson
$ python setup.py install

Requirements

Python2.7. Not tested in Python3+ after forking from pyrapidjson

Usage

Drop-in replacement for Python json module although function arguments to dump/load are not supported.

Example:

>>> import strrapidjson
>>> strrapidjson.loads('[1, 2, {"test": "hoge"}]')
>>> [1, 2, {'test': 'hoge'}]
>>> strrapidjson.dumps([1, 2, {"foo": "bar"}])
'[1,2,{"foo":"bar"}]'
>>>

Links

About

Python binding for rapidjson

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 58.9%
  • Python 40.3%
  • Makefile 0.8%