YAML to JSON type changes: quotes, comments and large integers
Successful conversion does not prove that an application receives the expected types. Use a version, a feature flag and a port list to define the intended types first, then compare the resulting values.
Open tool: YAML ↔ JSON converter1. Start with a small configuration
Convert the following with YAML → JSON. Expect version to remain the string "1.0", enabled to be a boolean and ports to be an array of numbers. Verify these explicit expectations before using the full configuration.
service: api
version: "1.0"
enabled: true
ports:
- 8080
- 80812. Quote values that must stay text
Versions, postal codes and identifiers often are not arithmetic values. Quoting them according to the configuration contract makes the string intent explicit. Remove the quotes from version and compare the resulting JSON type and value.
Null, an empty string and an absent field differ too. Try null, "" and removing the field separately instead of treating all visually empty results as equivalent.
3. Indentation defines structure; comments do not enter JSON
YAML indentation expresses hierarchy; use consistent spaces. Misindent a ports item, inspect the error and restore it. Even if output parses, check that an array has not become an unintended nested object.
JSON has no comment syntax. Conversion does not preserve YAML comments, quote styles or anchor notation. Keep the original as the editable source and use converted data where the consumer needs that format.
4. Formatting does not repair large integer precision
This converter rejects integers outside JavaScript’s safe range. An unquoted 9007199254740993 should not silently become a different value. If it is an identifier, represent it as a string when the API contract allows that.
Use the JSON formatter when you only need to inspect original number text. If an upstream system already rounded a number, conversion or quoting cannot recover it.
orderId: "9007199254740993"5. Verify a round trip by field
Convert the JSON output back to YAML, then compare fields, types and array order. Text diff reveals changes, but different quote styles or indentation do not necessarily mean changed data. Finally run the application’s configuration validator.
- Check booleans, nulls, numbers and strings separately.
- Check complex keys, custom tags and anchor-dependent configuration for compatibility separately.