Skip to content

cropsinsilico/yggdrasil-python-rapidjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,183 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yggdrasil-python-rapidjson

Python wrapper around YggdrasilRapidJSON

Authors: Meagan Lang <langmm.astro@gmail.com>
Ken Robbins [RapidJSON] <ken@kenrobbins.com>
Lele Gaifax [RapidJSON] <lele@metapensiero.it>
License:MIT License

YggdrasilRapidJSON is an extension to RapidJSON, an extremely fast C++ JSON parser and serialization library. This package wraps it into a Python C-extension, duplicating the functions/classes provided by python-rapidjson and exposing the features added by YggdrasilRapidJSON including serialization/deserialization of additional datatypes, unitful scalars/arrays, and schema normalization/comparison.

Getting Started

First install yggdrasil-python-rapidjson:

$ pip install yggdrasil-python-rapidjson

or, if you prefer Conda:

$ conda install -c conda-forge yggdrasil-python-rapidjson

Basic usage looks the same as python-rapidjson, with the exception of the package name (example adapted from python-rapidjson README.rst):

>>> import yggdrasil_rapidjson
>>> data = {'foo': 100, 'bar': 'baz'}
>>> yggdrasil_rapidjson.dumps(data)
'{"foo":100,"bar":"baz"}'
>>> yggdrasil_rapidjson.loads('{"bar":"baz","foo":100}')
{'bar': 'baz', 'foo': 100}
>>>
>>> class Stream:
...   def write(self, data):
...      print("Chunk:", data)
...
>>> yggdrasil_rapidjson.dump(data, Stream(), chunk_size=5)
Chunk: b'{"foo'
Chunk: b'":100'
Chunk: b',"bar'
Chunk: b'":"ba'
Chunk: b'z"}'

Development

If you want to install the development version (maybe to contribute fixes or enhancements) you may clone the repository:

$ git clone --recursive https://github.com/cropsinsilico/yggdrasil-python-rapidjson.git

Note

The --recursive option is needed because we use a submodule to include YggdrasilRapidJSON sources. Alternatively you can do a plain clone immediately followed by a git submodule update --init.

Alternatively, if you already have (a compatible version of) YggdrasilRapidJSON includes around, you can compile the module specifying their location with the option --config-settings=cmake.define.RAPIDJSON_INCLUDE_DIRS=, for example:

$ pip install . --config-settings=cmake.define.RAPIDJSON_INCLUDE_DIRS=/usr/include/rapidjson

The package can be built and installed from source via

$ pip install .

The package tests and doctests can be run via pytest

$ python -m pytest tests/ --doctest-glob="docs/*.rst" --doctest-modules docs

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 23