Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1,232 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 (NOTE: the conda-forge feedstock for yggdrasil-python-rapidjson is not yet available, but will be once the PR is merged):

$ 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 https://github.com/cropsinsilico/yggdrasil-python-rapidjson.git

The package can be built and installed from source via

$ pip install .

Note

The install command will clone a copy of the YggdrasilRapidJSON sources as part of the build process if an existing YggdrasilRapidJSON installation cannot be found (in the usual locations checked by cmake for your OS).

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

$ pip install . --config-settings=cmake.define.YGGDRASIL_RAPIDJSON_REPO_DIR=/usr/local/yggdrasil-rapidjson

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

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages