问题
I am starting to learn Azure dev-ops. You can configure your Azure-pipelines with yml. I was just wondering why did Microsoft go with yml. This could have been done with json as well. Just curious as to why not use a format that is quite popular?
回答1:
YAML is not as common as JSON, but it is also a popular and awesome data serialization language. The design goal of JSON is to be simpler and be universally usable. In contrast, the design goal of YAML is to provide a good human-readable format and give/provide support for serializing arbitrary native data structures. So this has increased the readability of the YAML files.
YAML official website shows the design in YAML format and it is easily readable for anyone visiting the site. On the other hand, if it was displayed in JSON format, the webpage would be useless.
JSON is a superset of YAML format. It means that we can parse JSON using a YAML parser. However, in practical scenarios, this parsing may rise problems, but it is theoretically possible. I think Microsoft wanted the data to be easily human-readable and simple, so they selected YAML!
回答2:
YAML is in a better position to be able to explain to you what the script is doing. The reason for this is that YAML is sold as a “human friendly” data serialisation language. JSON and XML are also data serialisation languages, but they weren't so much created with a focus on readability. After all, JSON doesn’t natively support comments (You'd have to use JSONC for that, or another implementation of JSON that supports comments).
YAML positions itself as a “human-readable data-serialisation” language. So the intent is clear - to make it easy to read and write structured data. This is an excerpt from this blog, you can refer to it.
来源:https://stackoverflow.com/questions/62868827/why-did-microsoft-not-go-with-json-instead-of-yml-for-azure-pipelines