2026-10-21 · 6 min read · Rahul Chitturi
- yaml
- json
- debugging
The YAML page parses with the yaml package and then prints JSON.stringify of that value at two spaces, plus a trailing newline. A box that trims to nothing returns an empty string before the parser runs. A box that still has a comment is not empty, and the parser result for a comment-only document is null.
Two other results look like missing data. Non-finite scalars become null in the JSON panel. A merge key is copied as the literal key << and is not applied to the surrounding map.
Read null as three different inputs
a: .inf, b: -.inf, and c: .nan parse as Infinity, -Infinity, and NaN. JSON.stringify has no token for those values, so the panel shows null for each one. .Inf and .NAN take the same path. The YAML text is still on the left. The nulls are the JSON encoding.
# only followed by a newline prints null and a newline. A box of spaces prints nothing, because trim runs first. ~, null, Null, and NULL inside a map are also JSON null, and that null is the scalar the author wrote. Diff the source against the panel before you treat every null as a deleted key.
- Keep the YAML beside the JSON.
- Treat .inf and .nan as null only after stringify.
- Treat a comment-only document as the JSON value null.
- Treat a whitespace-only box as no output.
Leave the merge key in place
An anchor is copied. a: &a {x: 1} and b: *a become two JSON objects that each contain x. A merge is different. base: &b with x: 1, then obj: <<: *b and y: 2, prints obj as a map whose first key is the characters << and whose value is {"x": 1}, followed by y. The page does not overlay x onto obj.
Duplicate keys throw before any JSON is printed. a: 1 then a: 2 returns Error: Map keys must be unique at line 2, column 1, and the message quotes the source. Copy copies that error text. A tab indent throws Tabs are not allowed as indentation. Two --- documents throw and name YAML.parseAllDocuments().
Check the numbers the JSON panel kept
0o10 becomes 8. 0x10 becomes 16. 010 becomes 10, and 08 becomes 8. 0b10 stays the string 0b10. 1.10 becomes 1.1. The integer 9007199254740993 becomes 9007199254740992. true, True, and TRUE are booleans. yes, Yes, on, and On stay strings.
Use the YAML tool for this conversion, the JSON formatter when you want the same text re-indented, and diff for the source against the panel. Quote the scalar and the JSON token together when a reviewer asks why a limit became null.