yapic.json
yapic.json is an extreamly fast json encoder / decoder package for python. Encoding and decoding output fully compatible with python.json package.
Features
Extreamly fast (see benchmark results in ‘/benchmark’ directory)
Fully compatible output with Python json package
Builtin object serialization method __json__ (see below)
Strict JSON (RFC 4627) expected: Infinity, NaN (JavaScript compatible infinity and not a number symbols)
UTF-8 encoding & decoding support
Accurate float encoding & decoding
date / datetime / time encondig & decoding support (can encode subclasses)
uuid.UUID encoding support
ItemsView encoding support
from collections.abc import ItemsView class MyDictGenerator(ItemsView): def __iter__(self): yield ("some_key", "some_value") yield ("meaning_of_life", 42) json.dumps(MyDictGenerator()) == '{"some_key":"some_value","meaning_of_life":42}'
Requirements
Only works with Python 3.5 or greater
c++ 11 comaptible compiler. (only if u want to build from source)
Wheels provided for windows x86/x64 and linux x86/x64 and osx x64
On Windows you maybe need to install Microsoft Visual C++ Redistributable
Windows
Usage
Very similar that python.json, let’s see some example
Json data to python
from yapic import json
>>> json.loads('"Hello World"')
"Hello World"
Python object to json data
from yapic import json
>>> json.dumps("Hello World")
'"Hello World"'
class Point:
def __json__(self):
return {"x":1, "y":2}
>>> json.dumps(Point())
'{"x":1,"y":2}'
Functions
loads (s: bytes, str, *, object_hook: Callable[[dict], Any]]=None, parse_float: Callable[[str], Any]]=None, parse_date: bool=True)
object_hook example:
>>> from yapic import json >>> def hook(dict_): ... if "__complex__" in dict_: ... return complex(dict_["real"], dict_["imag"]) ... >>> json.loads('{"__complex__":true, "real":1, "imag":2}', >>> object_hook=hook) (1+2j)parse_float example:
>>> from yapic import json >>> from decimal import Decimal >>> json.loads("1.2", parse_float=Decimal) Decimal('1.2')dumps (obj: Any, *, default: Callable[[Any], JSONT]=None, tojson: str="__json__", ensure_ascii: bool=True, encode_datetime: bool=True) -> str
default example:
>>> from yapic import json >>> def default_func(o): ... if isinstance(o, complex): ... return {"__complex__": True, "real": 1, "imag": 2} ... >>> json.dumps(1 + 2j, default=default_func) '{"__complex__":true,"real":1,"imag":2}'tojson example:
>>> from yapic import json >>> class Point(object): ... def __init__(self, x, y): ... self.x = x ... self.y = y ... def __json__(self): ... return {"x": self.x, "y": self.y} ... >>> json.dumps(Point(10, 20)) '{"x":10,"y":20}'dumpb (obj: Any, *, default: Callable[[Any], JSONT]=None, tojson: str="__json__", ensure_ascii: bool=True, encode_datetime: bool=True) -> bytes
Same as dumps, but this function is return bytes insted of str
Exceptions
import json as py_json
class JsonError(ValueError):
"""Base exception for all json errors"""
class JsonEncodeError(JsonError):
"""Exception for encoding errors"""
class JsonDecodeError(JsonError, py_json.JSONDecodeError):
"""Exception for decoding errors
Can match python builtin ``json.JSONDecodeError``.
"""
# alias for easier switch from std json lib
JSONDecodeError = JsonDecodeError
Json to Python translations
Json |
Python |
|---|---|
“string” |
str |
42 |
int |
4.2, 4e2 |
float (unless you specify parse_float) |
Infinity |
float(“inf”) |
NaN |
float(“NaN”) |
true |
True |
false |
False |
null |
None |
2000-01-01 12:34:56 |
datetime without timezone |
2000-01-01 12:34:56Z |
datetime with utc timezone |
2000-01-01 12:34:56+0300 |
datetime with custom timezone |
2000-01-01 |
date |
10:12:34 |
time without timezone |
10:12:34+0300 |
time with custom timezone |
{…} |
dict (unless you specify object_hook) |
[…] |
list |
Python to Json translations
Python |
Json |
|---|---|
str |
“…” |
int(42) |
42 |
float(4.2), Decimal(4.2) |
4.2 |
float(“inf”), Decimal(“inf”) |
Infinity |
float(“nan”), Decimal(“nan”) |
NaN |
True |
true |
False |
false |
None |
null |
datetime |
“2000-01-01 12:34:56”, “2000-01-01T12:34:56+0300” |
date |
“2000-01-01” |
time |
“12:34:56”, “12:34:56+0300” |
UUID |
“aba04c17-6ea3-48c1-8dcd-74f0a9b79bee” |
Enum |
encoding Enum.value attribute |
dict, ItemsView, dataclass |
{…} |
list, tuple, set, iterable |
[…] |
Metadata
Release files for yapic.json 1.9.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yapic.json-1.9.5.tar.gz | 105.4 kB | Without provenance | Details for yapic.json-1.9.5.tar.gz |
Built distributions (wheels)
Total release size: 3.8 MB
Release files / yapic.json-1.9.5.tar.gz
| Download URL | yapic.json-1.9.5.tar.gz |
|---|---|
| Size | 105.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4c7a533b0670709fca9623f243e6bc5b6c0f67adbb4de508af2381c271e98b4
|
|
BLAKE2b-256 checksum How to use checksums |
3d355d52934c020bfbffaff2c09b311f65103655a25dd4182cd23984187b9872
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.11.10
|
Release files / yapic.json-1.9.5-cp312-cp312-win_amd64.whl
| Download URL | yapic.json-1.9.5-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 84.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3db5a5828efd0d207a74f71bd41ab7db995fe26920bff1e413b756b367691db2
|
|
BLAKE2b-256 checksum How to use checksums |
cb6e664b9557cf99e34783da9f2cb384817379cea2b8d5f02f73fe119023c4dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.12.6
|
Release files / yapic.json-1.9.5-cp312-cp312-win32.whl
| Download URL | yapic.json-1.9.5-cp312-cp312-win32.whl |
|---|---|
| Size | 77.8 kB |
| Tags | CPython 3.12 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
63036af738ccd4d3cf5a3446a2867ad62e78f66af21dcd73b77992a19ee43e15
|
|
BLAKE2b-256 checksum How to use checksums |
263deedd25e7497d7e761907705b99f8fb452e27a24f54be9d4d4cd505eec1b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.12.6
|
Release files / yapic.json-1.9.5-cp311-cp311-win_amd64.whl
| Download URL | yapic.json-1.9.5-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 83.9 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f8d37c115b31bdef135918a2f24e3bdbee128f16838ce44def5114dd48da2de1
|
|
BLAKE2b-256 checksum How to use checksums |
e9d44c7341485efead5d29d8230789fb44af3c6a27b57c54661aaf3e0bc389e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.11.9
|
Release files / yapic.json-1.9.5-cp311-cp311-win32.whl
| Download URL | yapic.json-1.9.5-cp311-cp311-win32.whl |
|---|---|
| Size | 77.3 kB |
| Tags | CPython 3.11 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
570a65975f312cf7118526e36349d914a3b736b79e6e005dae99e6dd1eb00fea
|
|
BLAKE2b-256 checksum How to use checksums |
90c8f409a334fea320b3505812ed190559e0b62ef53cbabe19428615ad974634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.11.9
|
Release files / yapic.json-1.9.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | yapic.json-1.9.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 610.6 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5cea756a8c786309690f95a76d49549094fc8c40ba8ea14b53cc484ffdbec885
|
|
BLAKE2b-256 checksum How to use checksums |
6eedebc25d60204cff64ed2182ae819a92df06afd8b9a1ce067d9026d52e759e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.10
|
Release files / yapic.json-1.9.5-cp310-cp310-win_amd64.whl
| Download URL | yapic.json-1.9.5-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 83.9 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5b5a42986def9908fab9da85ce35429f76a0f92b0c13e42660b5de921e0cb2b6
|
|
BLAKE2b-256 checksum How to use checksums |
89e34290f611ce9216af7252a07c7e08ea8831e83cab8d85925c9852f2b30f3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.10.11
|
Release files / yapic.json-1.9.5-cp310-cp310-win32.whl
| Download URL | yapic.json-1.9.5-cp310-cp310-win32.whl |
|---|---|
| Size | 77.2 kB |
| Tags | CPython 3.10 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
9b69e9d7a84aac758883c47e4eff379b64283be34da9804a3ce19373d0bf7361
|
|
BLAKE2b-256 checksum How to use checksums |
11cef1630faee68721ce2d0d7a4864ba0b9454dc66ff5d56bfb623e40a47663d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.10.11
|
Release files / yapic.json-1.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | yapic.json-1.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 575.4 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7e2955502171738e9bfd367dfe4680f8a21eeec5b5cef84b4bafb6b487fa05bb
|
|
BLAKE2b-256 checksum How to use checksums |
9b97cf6fed72febc22404ce36713653ec38715e1f73cfc63a58496bddd536482
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.10
|
Release files / yapic.json-1.9.5-cp39-cp39-win_amd64.whl
| Download URL | yapic.json-1.9.5-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 84.0 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
be226bc8b20af020b2453c017ac753d5ae48cb5989386f0dc8910a861750f3f4
|
|
BLAKE2b-256 checksum How to use checksums |
02ac4b01db28bb6eb315c523c0210b32e723d4a3cecdae6ff155fa01777a2166
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.9.13
|
Release files / yapic.json-1.9.5-cp39-cp39-win32.whl
| Download URL | yapic.json-1.9.5-cp39-cp39-win32.whl |
|---|---|
| Size | 77.2 kB |
| Tags | CPython 3.9 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
5abaa56b65cdb5d72fa6878339296edfb7702bb3893031662753fec52cb7fa12
|
|
BLAKE2b-256 checksum How to use checksums |
c62aeccd59bf1411db491dcd33f9addacec2989193ab39142bb8464eace575bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.9.13
|
Release files / yapic.json-1.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | yapic.json-1.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 573.8 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7c3cc99d44e57d1e214c9c2e0be70c98123e602efb7b2be0161268c456cfc4d5
|
|
BLAKE2b-256 checksum How to use checksums |
db4d37f0a6036e755a5f76eb2a3d1130384d3f00dcee3b9a0cbdc7aeabc87451
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.10
|
Release files / yapic.json-1.9.5-cp38-cp38-win_amd64.whl
| Download URL | yapic.json-1.9.5-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 84.1 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fefe71a6d64fbcd69ea12bfe820c91d7fa8148369970ff61fa7ac29456df92c4
|
|
BLAKE2b-256 checksum How to use checksums |
7cc1f4c4dff34dc6a6b39519d643dd8b147e2f93c49fb5c41068e3e25b5922c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.8.10
|
Release files / yapic.json-1.9.5-cp38-cp38-win32.whl
| Download URL | yapic.json-1.9.5-cp38-cp38-win32.whl |
|---|---|
| Size | 77.2 kB |
| Tags | CPython 3.8 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
71e6eac1d1bead9ce1107312d567d0ba74802fe34e2db2dba50d24b9286551f5
|
|
BLAKE2b-256 checksum How to use checksums |
28c8fb65c09a6f9724b2b6c70fb73519743b74754cfdaa702830b7cb51418567
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.8.10
|
Release files / yapic.json-1.9.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | yapic.json-1.9.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 579.9 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e9d2ac05d561e13bb6364aa08b5afbddd4531968e434595ae99d1ec9fca23bf8
|
|
BLAKE2b-256 checksum How to use checksums |
78543b6baf1059ec582691dd7be210119e1acd3ac78b5805d6e3729e7ecbcd11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.10
|
Release files / yapic.json-1.9.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | yapic.json-1.9.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 541.3 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
1a6895cc0a8942202da85b64b3fbecfcdf1519676f92c539d89418df25e5845b
|
|
BLAKE2b-256 checksum How to use checksums |
4c513ce5602196422eb171004946762f1f019168e0f1e2297c6ce11f6347bb2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.10
|
Security for yapic.json 1.9.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.