NPM酷库,每天两分钟了解一个流行的NPM库。·在npm酷库044,我们了解了JSON5,??它比JSON格式更容易编写和维护。今天我们继续学习另一种数据格式YAML,更简单易读。以下是YAML数据的示例:---收据:Oz-WarePurchaseInvoicedate:2012-08-06customer:#objectgiven:Dorothyfamily:Galeitems:#objectarray-part_no:A4786describe:WaterBucket(Filled)价格:1.47数量:4-part_no:E1628描述:“Ruby”高跟拖鞋尺寸:8价格:133.7数量:1bill-to:&id001#anchormarkerid001street:|#multilinestring123TornadoAlleySuite16city:EastCentervillestate:KSship-to:*id001#参考锚标签id001specialDelivery:>#multilinestring沿着黄砖路前往翡翠城。不要注意窗帘后面的那个人。...YAML格式可以与JSON相比,YAML格式更易于人类编写和理解,因此更适合编写配置文件而不是JSON。js-yamljs-yaml是一个专门用来读写YAML格式数据的库。它可以将JS对象转为YAML字符串,也可以将YAML字符串转为JS对象。constyaml=require('js-yaml');constfs=require('fs')让obj=yaml。safeLoad(fs.readFileSync('example.yml','utf8'));让str=yaml。safeDump(obj);默认值http://yaml.orghttps://zh.wikipedia.org/wiki...https://github.com/nodeca/js-。
