When a Record Round Trip Is Lossless
A round trip is lossless relative to specified information. It can preserve a parsed value while changing formatting, member order, or exact bytes.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Compare one numeric field
Parsing "007" as a count and formatting it as "7" preserves seven. Treating the same field as an ID would lose its leading zeros. Parsing and formatting links the choice to the field's domain.
Choose the right equality check
A byte-for-byte archive and an interoperable settings export have different requirements. State which equals the original in a round-trip test before selecting the normalization.[1]
Choose which properties must survive reserialization
A JSON reader can parse objects with different formatting into the same internal mapping. Re-encoding may change spaces or member order yet preserve data values. A byte-identical round trip additionally needs original lexical information or a canonical source under an agreed serializer. See encoding and decoding.
Input A: {"n":2}
Input B: { "n" : 2 }
Both read as the same mapping
A default writer need not reproduce both original spellings
Test distinctions the format actually promises
Numeric spellings, unknown fields and duplicate members can be lost during normalization. Which losses are permitted depends on the exchange contract. Check round trips on current and older records as well as an unsupported version.