Migration from v1¶
datason v2 is a ground-up rewrite. The API has changed significantly.
Quick Summary¶
| v1 | v2 |
|---|---|
datason.serialize(obj) |
datason.dumps(obj) |
datason.deserialize(data) |
datason.loads(json_str) |
datason.dump_ml(obj) |
datason.dumps(obj, **ml_config().__dict__) |
datason.load_smart(data) |
datason.loads(json_str) |
| 100+ public functions | 5 functions: dumps, loads, dump, load, config |
| Python 3.8+ | Python 3.10+ |
| Monolithic core | Plugin-based architecture |
Key Changes¶
-
API reduced to 5 functions. All the
dump_ml,load_smart,load_perfect,save_stringvariants are gone. Usedatason.dumps()with config overrides or presets instead. -
Configuration via kwargs or context manager, not separate functions:
-
Type metadata key changed from various formats to a consistent
{"__datason_type__": "...", "__datason_value__": ...}envelope. -
Python 3.10 minimum. Drops 3.8/3.9 support. Uses
match/caseandX | Yunion syntax. -
Thread-safe by default. Config uses
contextvars.ContextVar, registry usesthreading.Lock.