Metadata-Version: 2.4
Name: bream
Version: 0.0.1
Summary: Explicitly versioned JSON serialisation
Project-URL: Homepage, https://github.com/tpgillam/bream
Author-email: Tom Gillam <tpgillam@googlemail.com>
License: MIT License
        
        Copyright (c) 2025 Tom Gillam
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# **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:
```json
{
    "_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:
```json
{
    "_type_label": "complex",
    "_version": 1,
    "_payload": {
        "real": 0.123,
        "imag": 0.456
    }
}
```
The three top-level fields are special:
- `_type_label` is a unique label for the type.
- `_version` is incremented whenever the structure of `_payload` needs to change.
- `_payload` is 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 `Coder`s 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.
