What problem does it solve?
Ensures consistent and high-performance JSON serialization, preventing data inconsistencies and improving processing speed in critical utility functions.
Core Features & Use Cases
- Deterministic Ordering: Guarantees that JSON output is always sorted by keys, essential for caching and comparisons.
- High Performance: Leverages the
orjson library for significantly faster serialization than the standard json module.
- Robust Fallback: Includes a fallback to
json.dumps for unsupported types or serialization errors, maintaining stability.
- Use Case: When serializing complex Python objects for cache keys or inter-service communication,
lib-orjson ensures that the resulting JSON strings are identical every time, preventing cache misses and ensuring reliable data exchange.
Quick Start
Ensure all orjson.dumps calls in flext-core/src/flext_core/_utilities/validation.py include option=orjson.OPT_SORT_KEYS and decode the output to a string using c.Utilities.DEFAULT_ENCODING.