Metadata-Version: 2.2
Name: yggdrasil-python-rapidjson
Version: 1.21.0.1
Summary: Version of rapidjson Python wrapper with extended support for yggdrasil
Keywords: yggdrasil,json,jsonc,rapidjson
Author-Email: Meagan Lang <langmm.astro@gmail.com>
Maintainer-Email: Meagan Lang <langmm.astro@gmail.com>
License: python-rapidjson is licensed under the MIT license.
         
         The MIT License (MIT)
         
         Copyright (c) 2015, 2016, 2017 Ken Robbins
         Copyright (c) 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Lele Gaifax
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python
Project-URL: Repository, https://github.com/cropsinsilico/yggdrasil-python-rapidjson
Requires-Python: >=3.9
Requires-Dist: numpy
Description-Content-Type: text/x-rst


===========================
 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 <https://raw.githubusercontent.com/cropsinsilico/yggdrasil-python-rapidjson/yggdrasil/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 <https://github.com/python-rapidjson/python-rapidjson>`_ and exposing the features added by YggdrasilRapidJSON_ including serialization/deserialization of additional datatypes, unitful scalars/arrays, and schema normalization/comparison.

.. TODO: Documentation link
.. TODO: https://python-rapidjson.readthedocs.io/en/latest


Getting Started
---------------

First install ``yggdrasil-python-rapidjson``:

.. code-block:: bash

    $ pip install yggdrasil-python-rapidjson

or, if you prefer `Conda <https://conda.io/docs/>`_:

.. code-block:: bash

    $ 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):

.. code-block:: python

    >>> 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:

.. code-block:: bash

    $ 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:

          .. code-block:: shell

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

The package can be built and installed from source via

.. code-block:: bash

    $ pip install .

The package tests and doctests can be run via pytest

.. code-block:: bash

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

    
.. _YggdrasilRapidJSON: https://github.com/cropsinsilico/yggdrasil-rapidjson
.. _RapidJSON: http://rapidjson.org/
.. _PythonRapidJSON: https://github.com/python-rapidjson/python-rapidjson
