Convert YAML to TOON and Check Value Types
Admin ·
Before using TOON to send configuration data to an application or model, check the types YAML assigned to the values. A plain numeric token and a quoted identifier can look similar in the source while carrying different data.
Read the typed inventory fields
Select Load example and Convert to TOON. Both items have the same keys, so they appear below one header named items[2]{code,active,count}. The first row holds the string 0012, Boolean true and number 2. The second row holds 0042, false and 0.
Outside the table, note is null and blank is the empty string. Remove the quotes around 0012 and convert again. The first code becomes the number 12 because YAML reads it as an integer. Restore the quotes for the rest of the example.
YAML 1.2.2 core schema and tag resolutionTOON specification, arrays, types and delimiters
Change the TOON delimiter and reopen the file
Select Pipe under TOON delimiter and convert again. The TOON header becomes items[2|]{code|active|count}. The first item still has the quoted code 0012 and the same Boolean and number.
Download the TOON and open it in TOON Validator. Check the decoded JSON contains two items, the exact codes in string quotes, and distinct values for null and the empty string. The separator changed the layout while the data stayed the same.
Repair numeric, key and alias diagnostics
Replace code with an unquoted 9007199254740993 in the first item and convert. The diagnostic points to the YAML number because its digits would change in the TOON codec. Quote the value to preserve it as a string. The same string option applies to special text such as .inf if the destination expects those characters.
Quote numeric or Boolean mapping keys so TOON can use them as object names. Earlier anchors can be expanded as values, while cyclic aliases trigger an error. YAML comments and anchor names are omitted.
YAML 1.2.2 core schema and tag resolutionTOON specification, arrays, types and delimiters
Common questions
What happens to an array whose objects have different keys?
The encoder can use a list instead of a shared tabular header. The varying keys and the order of array entries remain.
Can I convert two YAML documents separated by three hyphens?
Convert each document separately. Each export represents one YAML document.