Plain Text and Structured Text Files

A structured text format has a grammar defining record boundaries, field names, or types. Following that grammar is how a reader recovers data.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Compare two exports
  2. Identify what a human label omits
  3. Separate successful decoding from successful parsing
  4. Preserve the distinction for readers of diagnostics

Compare two exports

A note reading Height 12 requires an external convention about its quantity and unit. A JSON object with separate height and unit fields preserves their names but still needs a contract about units. Type-aware record conversion gives that boundary.

Identify what a human label omits

A formatted summary might round a value and drop an unknown field. A data export has to carry each field recipients require. Parsing and formatting separates those purposes.[1]

Separate successful decoding from successful parsing

A file containing {"count": 2 is valid UTF-8 text yet has incomplete JSON syntax. A file containing {"count": "two"} can parse as JSON while violating an integer field rule. The layers answer distinct questions about the same bytes. See structural and domain validation.

Step 1: bytes → characters
Step 2: characters → parsed data structure
Step 3: check expected fields and values
An error report can identify the first failing step

Preserve the distinction for readers of diagnostics

A decoding error needs an encoding or byte location. A syntax error can cite a token or opening delimiter. A schema error names the field expected by the consumer. Test one invalid input per layer.

References

  1. IETF, RFC 3629: UTF-8, a Transformation Format of ISO 10646 ↩