There are a number of additional features in YAML that are not present in JSON:
- The comments, which begin with # and continue to the end of the line. They can go almost anywhere. JSON doesn't tolerate comments.
- The document start, which is indicated by the --- line at the start of a new document. This allows a YAML file to contain many individual objects. JSON is limited to a single document per file. The alternative to one document-per-file is somewhat a more complex parsing algorithm. YAML provides an explicit document separator and a very simple parsing interface.
- The YAML file with two separate documents:
>>> import yaml >>> yaml_text = ''' ... --- ... id: 1 ... text: "Some Words." ... --- ... id: 2 ... text: "Different ...