I'm asking about the reason for using YAML for package managing pubspec.yaml
in Dart, why did they choose YAML, not JSON? what is the unique thing in YAML that makes it a favourite for this purpose instead of another?

- 4,198
- 5
- 17
- 50

- 13
- 2
-
Does this answer your question? [What is the difference between YAML and JSON?](https://stackoverflow.com/questions/1726802/what-is-the-difference-between-yaml-and-json) – a7md0 Sep 26 '22 at 17:39
-
The nice thing about it being YAML is that since JSON is a proper subset, you can just drop in a JSON representation for all or part of your YAML file. I do that when I get frustrated lining up the assets sometimes. :) – Randal Schwartz Sep 26 '22 at 18:25
-
Why JSON? JSON is intended to be a data serialization format. That does not necessarily make it good for configuration files, particularly due to its lack of comments. Personally I'd prefer a subset of Dart. – jamesdlin Sep 26 '22 at 22:50
3 Answers
What is the difference between YAML and JSON?
Most importantly support for comments & Better readability

- 429
- 2
- 10
- 20
In my opinion:
1. Readability
YAML is much better... Like Python
2. Commentary
In JSON you can't give comments For flutter/Dart application maintenance, of course requires comments since the PUBSPEC file was created.
3. Speed
Indeed JSON files are smaller and faster, but for cross-platform developers, more emphasis on ease of reading and speed of production. Moreover, the development of mobile hardware is now very good.
4. Complexity
JSON structure is simpler, so it does not support complex configurations.
But, YAML... be aware that "white space" (tabs v spaces) matters.

- 326
- 4
- 11
The design goal of JSON is to be as simple as possible and be universally usable. This has reduced the readability of the data, to some extent. In contrast, the design goal of YAML is to provide a good human-readable format and provide support for serializing arbitrary native data structures.
Source: JSON vs. YAML: A Dive Into 2 Popular Data Serialization Languages

- 4,198
- 5
- 17
- 50