Skip to content
Snippets Groups Projects
Commit 6c9c89d1 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

fix readme

parent c63c6368
No related branches found
No related tags found
No related merge requests found
......@@ -8,68 +8,15 @@ Usage
-----
As usual, please [RTFM](minijson/routines.pxd).
Here's the [specification](specification.md) of MiniJSON
Here's the [specification](specification.md) of MiniJSON.
It works pretty the same as pyyaml or json:
Refer to the [documentation](http://minijson.readthedocs.io/en/latest/?badge=latest)
for use.
```python
from minijson import dumps, loads
If there are no binary wheels precompiled for this platform, you will need to compile it yourself.
b_bytes = dumps({'hello': 'world'})
data = loads(b_bytes)
assert data == {'hello': 'world'}
In order to do that you must have the following packages installed:
import io
from minijson import dump
cio = io.BytesIO()
dump({'hello': 'world'}, cio)
```
By defaults floats are encoded as IEEE 754 singles. To force them to be encoded as doubles, do:
```python
from minijson import switch_default_float, switch_default_double
switch_default_double()
# now everything is encoded as a double
switch_default_float()
# and now as float
```
Exceptions
----------
```python
from minijson import MiniJSONError, EncodingError, DecodingError
assert issubclass(MiniJSONError, ValueError)
assert issubclass(DecodingError, MiniJSONError)
assert issubclass(EncodingError, MiniJSONError)
```
Loading and dumping objects
---------------------------
Assume you have an object defined like this:
```python
class Test:
def __init__(self, a):
self.a = a
def __eq__(self, o):
"""Not necessary"""
return self.a == o.a
```
You can use provided methods to serialize and unserialize it:
```python
from minijson import loads_object, dumps_object
a = Test(2)
b = dumps_object(a)
c = loads_object(b, Test)
assert a == c
```
* snakehouse
* satella
* Cython
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment