How to convert JSON to YAML (and back) without breaking things

JSON ↔ YAML looks simple until you hit anchors, multi-line strings, booleans that aren't booleans, and the Norway problem.