Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minijson
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
minijson
Commits
6c9c89d1
Commit
6c9c89d1
authored
4 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
fix readme
parent
c63c6368
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+8
-61
8 additions, 61 deletions
README.md
with
8 additions
and
61 deletions
README.md
+
8
−
61
View file @
6c9c89d1
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment