Provides a canonical JSON encoder and normalizer for deterministic byte output across Swift.
// Source: https://github.com/osaurus-ai/osaurus | License: MIT | Copyright 2026 Osaurus, Inc // Provided via justclaw.it.com; keep this notice with the code. // // JSONDeterminism.swift // osaurus // // Centralised canonical-encoding contract for any JSON Osaurus emits where // byte order matters: outbound HTTP bodies to remote model providers, // tool-result strings replayed into the next-turn prompt, server responses // to MCP / Anthropic / OpenAI / Ollama clients, and any payload hashed for // cache keys or sync digests. // // Background and per-site rationale: see `docs/JSON_DETERMINISM.md`. // TL;DR: Swift `Dictionary` and `JSONValue.object` have no stable iteration // order, so `JSONEncoder()` / `JSONSerialization.data(withJSONObject:)` // produce different bytes for the ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key