将 yaml 输入翻转为 json,反之亦然
项目描述
Flamel - 将 YAML 转换为 JSON,和/或 JSON 转换为 YAML
就像 Nicholas Flamel 一样,当他需要金币时,他可以简单地抓住一堆铅并将其转化为金币,当您需要 JSON 时,flamel 会将您的一堆 YAML 转化为 JSON。如果您希望这样做,它还会将您的 JSON 转换为 YAML。
几个特点:
- 尝试检测输入并切换到替代
- 维护从输入到输出的映射中键的顺序
安装
芝士店有flamel:https ://pypi.org/project/flamel/
你可以安装它pip install flamel
看到它在行动
$ cat foo.yaml
things:
- thing1
- thing2
other:
mapping: 9999
$ flamel foo.yaml
{
"things": [
"thing1",
"thing2"
],
"other": {
"mapping": 9999
}
}
$ flamel foo.yaml > foo.json
$ flamel foo.json
things:
- thing1
- thing2
other:
mapping: 9999