:py:mod:`ethos_penalps.utilities.own_object_json_encoding_decoding`
===================================================================

.. py:module:: ethos_penalps.utilities.own_object_json_encoding_decoding


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   ethos_penalps.utilities.own_object_json_encoding_decoding.ExtendedEncoder
   ethos_penalps.utilities.own_object_json_encoding_decoding.ExtendedDecoder
   ethos_penalps.utilities.own_object_json_encoding_decoding.MyEncoder
   ethos_penalps.utilities.own_object_json_encoding_decoding.MyDecoder




.. py:class:: ExtendedEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)


   Bases: :py:obj:`json.JSONEncoder`

   Extensible JSON <https://json.org> encoder for Python data structures.

   Supports the following objects and types by default:

   +-------------------+---------------+
   | Python            | JSON          |
   +===================+===============+
   | dict              | object        |
   +-------------------+---------------+
   | list, tuple       | array         |
   +-------------------+---------------+
   | str               | string        |
   +-------------------+---------------+
   | int, float        | number        |
   +-------------------+---------------+
   | True              | true          |
   +-------------------+---------------+
   | False             | false         |
   +-------------------+---------------+
   | None              | null          |
   +-------------------+---------------+

   To extend this to recognize other objects, subclass and implement a
   ``.default()`` method with another method that returns a serializable
   object for ``o`` if possible, otherwise it should call the superclass
   implementation (to raise ``TypeError``).


   .. py:method:: default(obj)

      Implement this method in a subclass such that it returns
      a serializable object for ``o``, or calls the base implementation
      (to raise a ``TypeError``).

      For example, to support arbitrary iterators, you could
      implement default like this::

          def default(self, o):
              try:
                  iterable = iter(o)
              except TypeError:
                  pass
              else:
                  return list(iterable)
              # Let the base class default method raise the TypeError
              return JSONEncoder.default(self, o)




.. py:class:: ExtendedDecoder(**kwargs)


   Bases: :py:obj:`json.JSONDecoder`

   Simple JSON <https://json.org> decoder

   Performs the following translations in decoding by default:

   +---------------+-------------------+
   | JSON          | Python            |
   +===============+===================+
   | object        | dict              |
   +---------------+-------------------+
   | array         | list              |
   +---------------+-------------------+
   | string        | str               |
   +---------------+-------------------+
   | number (int)  | int               |
   +---------------+-------------------+
   | number (real) | float             |
   +---------------+-------------------+
   | true          | True              |
   +---------------+-------------------+
   | false         | False             |
   +---------------+-------------------+
   | null          | None              |
   +---------------+-------------------+

   It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
   their corresponding ``float`` values, which is outside the JSON spec.


   .. py:method:: object_hook(obj)



.. py:class:: MyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)


   Bases: :py:obj:`ExtendedEncoder`

   Extensible JSON <https://json.org> encoder for Python data structures.

   Supports the following objects and types by default:

   +-------------------+---------------+
   | Python            | JSON          |
   +===================+===============+
   | dict              | object        |
   +-------------------+---------------+
   | list, tuple       | array         |
   +-------------------+---------------+
   | str               | string        |
   +-------------------+---------------+
   | int, float        | number        |
   +-------------------+---------------+
   | True              | true          |
   +-------------------+---------------+
   | False             | false         |
   +-------------------+---------------+
   | None              | null          |
   +-------------------+---------------+

   To extend this to recognize other objects, subclass and implement a
   ``.default()`` method with another method that returns a serializable
   object for ``o`` if possible, otherwise it should call the superclass
   implementation (to raise ``TypeError``).


   .. py:method:: encode_BatchStream(batch_stream: ethos_penalps.stream.BatchStream) -> dict


   .. py:method:: encode_ContinuousStream(continuous_stream: ethos_penalps.stream.ContinuousStream) -> dict


   .. py:method:: encode_StreamHandler(stream_handler: ethos_penalps.stream_handler.StreamHandler) -> dict



.. py:class:: MyDecoder(**kwargs)


   Bases: :py:obj:`ExtendedDecoder`

   Simple JSON <https://json.org> decoder

   Performs the following translations in decoding by default:

   +---------------+-------------------+
   | JSON          | Python            |
   +===============+===================+
   | object        | dict              |
   +---------------+-------------------+
   | array         | list              |
   +---------------+-------------------+
   | string        | str               |
   +---------------+-------------------+
   | number (int)  | int               |
   +---------------+-------------------+
   | number (real) | float             |
   +---------------+-------------------+
   | true          | True              |
   +---------------+-------------------+
   | false         | False             |
   +---------------+-------------------+
   | null          | None              |
   +---------------+-------------------+

   It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
   their corresponding ``float`` values, which is outside the JSON spec.


   .. py:method:: decode_BatchStream(batch_stream_dictionary: dict) -> ethos_penalps.stream.BatchStream


   .. py:method:: decode_ContinuousStream(continuous_stream_dictionary: dict) -> ethos_penalps.stream.ContinuousStream


   .. py:method:: decode_StreamHandler(stream_handler_dict: dict) -> ethos_penalps.stream_handler.StreamHandler



