ConvertersLesson 23Free preview
JSON to YAML
This lesson is part of Web Developer Tools · All levels
Summary
The JSON to YAML converter converts JSON objects and arrays into YAML text using the indentation as a structural marker. JSON is more compact with curly braces and quotes, while YAML is more readable for configuration files. The converter maps the object into a mapping, arrays into a minus-marked list, and maintains a boolean value or a fixed number. Since JSON has no comments, YAML results also do not carry any comments.
Key points
- JSON object to YAML mapping with key pairs: value
- JSON arrays to list YAML that begin with minus
- YAML's index should be consistent and not use a tab.
- Value string with special characters may need to be quoted
- Comments don't follow because JSON doesn't support comments
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.