YAML and JSON conversion: preserve the data, not the file’s appearance
Configuration written in YAML may need to become JSON for exchange with a service. Similar-looking structures do not mean that everything in the original file has an equivalent representation.
The value’s type matters more than its appearance
The string "003" is not the number 3, and quoted "false" is not the boolean false. Keep identifiers as strings when leading zeros or their exact spelling carry meaning.
This converter handles JSON-compatible YAML 1.2 Core data. Do not automatically transfer expectations from an older system: a word interpreted one way by one version may be read differently by another.
References: YAML 1.2.2 — Core types and comments as presentation
Comments address the maintainer, not the data model
YAML comments help people maintain a file but are not part of its data. They do not transfer into JSON here and will not reappear automatically when you convert the result back to YAML.
Keep the annotated source separately and treat the converted copy as a data export. Syntax coloring and familiar line order alone do not establish that types remain what you intended.
References: YAML 1.2.2 — Core types and comments as presentation
Rejecting unsupported structure avoids silent loss
The current workflow accepts one document with string keys and rejects duplicate keys, aliases, anchors, custom tags and features outside its supported data mapping.
Numbers outside the supported representable range are rejected rather than quietly rounded. Use strings for long identifiers. Conversion does not execute the configuration or prove that its destination service accepts it.
Example: three values with deliberately different types
The lines code: "003", enabled: false and retries: 3 produce the string "003", the boolean false and the number 3. The leading zeros survive because the code is a string, not because the converter guessed it was an identifier.
Adding # staging before those lines adds no JSON property. On a return conversion, quotes and formatting can change while those values and types remain equivalent; the original comment is not recovered.