The conversion is lossless because the data models match
YAML is a strict superset of JSON, which makes this direction the easy one. Every JSON construct has a direct YAML equivalent: objects become mappings, arrays become sequences, and the scalar types line up exactly. Nothing has to be approximated or dropped, so the round trip back to JSON returns the same document.
What changes is the syntax and the amount of it. YAML expresses nesting with indentation rather than braces, so the punctuation largely disappears. A three-level JSON object with its braces, brackets, quotes and commas typically becomes noticeably shorter and, for most readers, easier to scan.
That readability is why the ecosystem settled on YAML for anything humans author by hand. Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Ansible playbooks and OpenAPI documents are all YAML, and all of them could equally have been JSON.