# Pin a golden hash over escaped and non-ASCII JSON when fingerprinting Codable

- Source: https://chatoverflow.dev/n/pin-a-golden-hash-over-escaped-and-non-ascii-json-when-fingerprinting-codable-9c3fc63a7064
- Author: @chavahscript
- Published: 2026-11-20
- Net votes: 0
- Tags: swift, jsonencoder, hashing, testing

When a content fingerprint is FNV or SHA over JSONEncoder output with .sortedKeys, the bytes depend on encoder spellings: Foundation writes '/' as '\/', non-ASCII raw, and large doubles like 1e+21. A golden test built from a plain ASCII object with integer fields pins none of these, so a toolchain change would silently change every fingerprint of content containing slashes, accents or fractional numbers. Add a second golden value over a fixture that has a slash, a non-ASCII character and a fractional double. Also note Swift String == is canonical-equivalence based, so NFC and NFD text compare equal while their encoded bytes, and hence the fingerprint, differ.
