diff --git a/README.md b/README.md index a924bd118518703a4c378ff05e4cec2acf8b122b..7e3e3d90d07dd6f2879f620723ba9dcaf87fa426 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ MiniJSON ======== +[](http://minijson.readthedocs.io/en/latest/?badge=latest) + +MiniJSON is a codec for a compact binary representation of a subset of JSON. Usage ----- diff --git a/docs/usage.rst b/docs/usage.rst index 0c73cb94bdd572bb890f214970fa5393cb126c77..f985e4b7c45b5161b30b461efa36dc94d433df94 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -24,3 +24,39 @@ And the following exceptions: .. autoclass:: minijson.EncodingError .. autoclass:: minijson.DecodingError + +Controlling float output +------------------------ + +By default, floats are output as IEEE 754 single. To switch to double just call: + +.. autofunction:: minijson.switch_default_double + +or to go again into singles: + +.. autofunction:: minijson.switch_default_float + +Serializing objects +------------------- + +If you got an object, whose entire contents can be extracted from it's :code:`__dict__`, +and which can be instantiated with a constructor providing this :code:`__dict__` as keyword +arguments to the program, you can use functions below to serialize/unserialize them: + +.. autofunction:: minijson.dumps_object + +.. autofunction:: minijson.loads_object + +Example: + +.. code-block:: python + + from minijson import loads_object, dumps_object + + class Test: + def __init__(self, a): + self.a = a + + a = Test(3) + b = dumps_object(a) + loads_object(b, Test) diff --git a/minijson/__init__.py b/minijson/__init__.py index 709fcab90d34926cbd13362ba466b4c7f411bdd0..fd95c4a14ebdab8ebd6a169b49e8fc07138fdedf 100644 --- a/minijson/__init__.py +++ b/minijson/__init__.py @@ -1,3 +1,6 @@ from .routines import dumps, loads, switch_default_double, switch_default_float, \ - dumps_object, loads_object + dumps_object, loads_object, parse, dump from .exceptions import MiniJSONError, EncodingError, DecodingError + +__all__ = ['dumps', 'loads', 'switch_default_float', 'switch_default_double', + 'dumps_object', 'loads_object', 'parse', 'dump']