Explicitly versioned JSON serialisation
Project description
WARNING
bream is currently in pre-alpha development, and does NOT yet have a stable serialisation format.
Any release in the 0.0.x series may contain breaking changes.
Please do test-drive and give feedback, or else check back soon for a stable version!
END WARNING
bream
bream is an explictly versioned encode/decode framework targetting JSON-like trees.
Goals and non-goals
bream aims to be the following:
- Simple: encode to a human-readable JSON tree.
- Explicit: no silent conversion. User-provided versions, easy upgrades.
- Modular: bring-your-own codecs.
It does not aim to be fast. Speed isn't a current design goal.
Data structure
A JSON-like tree is a nested combination of dict (with str keys only), list, int,
float, str, bool and None.
An bream tree is a dict with some metadata and a payload; any valid JSON tree is a valid
payload. For example:
{
"_bream_spec": 1,
"_payload": {
"serialised": ["data", "goes", "here"]
}
}
Any JSON tree is a valid bream payload.
Encoded objects
Certain JSON trees within a payload represent 'encoded' Python objects. Any such tree
is a dict with a particular structure. Here's how complex(0.123, 0.456) might be
encoded:
{
"_type_label": "complex",
"_version": 1,
"_payload": {
"real": 0.123,
"imag": 0.456
}
}
The three top-level fields are special:
_type_labelis a unique label for the type._versionis incremented whenever the structure of_payloadneeds to change._payloadis some JSON data (that may or may not be a dict).
A Coder is an object which knows how to convert from the payload back to a Python
object.
Advantages of versioning
The main advantage of explicitly encoding & decoding your objects with bream is the ability to version the encoded form, and then provide a "compatibility decode" pathway to decode an older encoded representation into the latest in-memory representation.
This also means that upgrading an 'old' file on disk is as simple as decoding then encoding again.
Separating the Coders from the type being encoded also has the advantage that you can
write custom serialisation for builtin or third-party types not under your direct
control.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bream-0.0.2.tar.gz.
File metadata
- Download URL: bream-0.0.2.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0a3f891ec28b7577d3b0d42cc292be200c291431b42b5a4a528e3872f3033f7
|
|
| MD5 |
ba247118af84e41e091bc32e6d7a37d8
|
|
| BLAKE2b-256 |
6ea8c7f8e521772818d7782b78a25ce5ca0e0095276bc0f277bba466c4d1bb9d
|
File details
Details for the file bream-0.0.2-py3-none-any.whl.
File metadata
- Download URL: bream-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1f45c444094db875a71e688f0316c36a7eb97ad4319e3d0b44cbb9242f395ff
|
|
| MD5 |
2c8960bc3013e629ffcc9201f8c0ea0a
|
|
| BLAKE2b-256 |
68de11c3991d3954446a908199d0b67494f0659e3356ae57cea33a856835f08a
|