经过:原本,我一直以为,yml格式非常好用,至少比 properties要科学,比 json 要简洁、强大,然而,下面遇到的这个案例,让我意识到,yaml并不是万能,也并不是最科学、简洁的,甚至是比较糟糕的。
我有这样一个 spring-boot的配置文件(原本是properties格式如下):
|
还是比较直观,而且 借助复制粘贴 写起来倒也简单。
然而,我在另一个新项目中,想把它转换成 yaml格式,很快,我发现不妙,不信你可以试试。
我转换的结果是这样的:
|
转换费了我不少功夫,而且一看,这是什么玩意儿啊,乱七八糟的,不直观,反人类啊。
于是 我找到了一个 “像样的人类可读的格式”(easy for humans to read and write)
——那就是 TOML。
GitHub 目前的新项目已经转用 CoffeeScript 了。CoffeeScript 比JavaScript 要简洁优雅得多。
同样地,GitHub 也觉得 YAML 不够简洁优雅,因此捣鼓出了一个TOML。
TOML 的全称是 Tom's Obvious, Minimal Language,因为它的作者是 GitHub 联合创始人 Tom Preston-Werner 。
TOML 的目标
TOML 的目标是成为一个极简的配置文件格式。TOML 被设计成可以无歧义地被映射为哈希表,从而被多种语言解析。
例子
|
详见官方文档:https://github/toml-lang/toml/blob/master/versions/cn/toml-v0.5.0.md
TOML的实现和各种语言支持
如果你有一个实现,请发一个合并请求,把你的实现加入到这个列表中。请在你的解析器的 README 中标记你的解析器支持的 提交SHA1 或 版本号。
-
C#/.NET - https://github/LBreedlove/Toml
-
C#/.NET - https://github/rossipedia/toml-net
-
C#/.NET - https://github/RichardVasquez/TomlDotNet
-
C (@ajwans) - https://github/ajwans/libtoml
-
C++ (@evilncrazy) - https://github/evilncrazy/ctoml
-
C++ (@skystrife) - https://github/skystrife/cpptoml
-
Clojure (@lantiga) - https://github/lantiga/clj-toml
-
Clojure (@manicolosi) - https://github/manicolosi/clojoml
-
CoffeeScript (@biilmann) - https://github/biilmann/coffee-toml
-
Common Lisp (@pnathan) - https://github/pnathan/pp-toml
-
Erlang - https://github/kalta/etoml.git
-
Erlang - https://github/kaos/tomle
-
Emacs Lisp (@gongoZ) - https://github/gongo/emacs-toml
-
Go (@thompelletier) - https://github/pelletier/go-toml
-
Go (@laurent22) - https://github/laurent22/toml-go
-
Go w/ Reflection (@BurntSushi) - https://github/BurntSushi/toml
-
Haskell (@seliopou) - https://github/seliopou/toml
-
Haxe (@raincole) - https://github/raincole/haxetoml
-
Java (@agrison) - https://github/agrison/jtoml
-
Java (@johnlcox) - https://github/johnlcox/toml4j
-
Java (@mwanji) - https://github/mwanji/toml4j
-
Java - https://github/asafh/jtoml
-
Java w/ ANTLR (@MatthiasSchuetz) - https://github/mschuetz/toml
-
Julia (@pygy) - https://github/pygy/TOML.jl
-
Literate CoffeeScript (@JonathanAbrams) - https://github/JonAbrams/tomljs
-
node.js - https://github/aaronblohowiak/toml
-
node.js/browser - https://github/ricardobeat/toml.js (npm install tomljs)
-
node.js - https://github/BinaryMuse/toml-node
-
node.js (@redhotvengeance) - https://github/redhotvengeance/topl (topl npm package)
-
node.js/browser (@alexanderbeletsky) - https://github/alexanderbeletsky/toml-js (npm browser amd)
-
Objective C (@mneorr) - https://github/mneorr/toml-objc.git
-
Objective-C (@SteveStreza) - https://github/amazingsyco/TOML
-
Ocaml (@mackwic) https://github/mackwic/to.ml
-
Perl (@alexkalderimis) - https://github/alexkalderimis/config-toml.pl
-
Perl - https://github/dlc/toml
-
PHP (@leonelquinteros) - https://github/leonelquinteros/php-toml.git
-
PHP (@jimbomoss) - https://github/jamesmoss/toml
-
PHP (@coop182) - https://github/coop182/toml-php
-
PHP (@checkdomain) - https://github/checkdomain/toml
-
PHP (@zidizei) - https://github/zidizei/toml-php
-
PHP (@yosymfony) - https://github/yosymfony/toml
-
Python (@socketubs) - https://github/socketubs/pytoml
-
Python (@f03lipe) - https://github/f03lipe/toml-python
-
Python (@uiri) - https://github/uiri/toml
-
Python - https://github/bryant/pytoml
-
Python (@elssar) ) https://github/elssar/tomlgun
-
Python (@marksteve) - https://github/marksteve/toml-ply
-
Python (@hit9) - https://github/hit9/toml.py
-
Ruby (@jm) - https://github/jm/toml (toml gem)
-
Ruby (@eMancu) - https://github/eMancu/toml-rb (toml-rb gem)
-
Ruby (@charliesome) - https://github/charliesome/toml2 (toml2 gem)
-
Ruby (@sandeepravi) - https://github/sandeepravi/tomlp (tomlp gem)
-
Scala - https://github/axelarge/tomelette
校验
@BurntSushi) - https://github/BurntSushi/toml/tree/master/tomlv
TOML 测试套件 (语言无关)
-
toml-test (@BurntSushi) - https://github/BurntSushi/toml-test
编辑器支持
-
Emacs (@dryman) - https://github/dryman/toml-mode.el
-
Sublime Text 2 & 3 (@lmno) - https://github/lmno/TOML
-
TextMate (@infininight) - https://github/textmate/toml.tmbundle
-
Vim (@cespare) - https://github/cespare/vim-toml
编码器
-
PHP (@ayushchd) - https://github/ayushchd/php-toml-encoder
更多推荐
令人崩溃的yaml(yml配置)对比properties、json、TOML
发布评论