[英]Parsing a YAML file using js-yaml
I am using js-yaml to parse and read the contents of a yaml file in node js, this is a typical key value pair yaml, some of the keys in the Yaml have values in the format, example:我正在使用js-yaml来解析和读取节点js中yaml文件的内容,这是一个典型的键值对yaml,Z65F6036BFC9798CE230C5D85Z格式中的一些键的值例如:55Z
key : {{ val1 }} {{ val2 }}
The parsing is failing at such instances in the file.在文件中的此类实例中解析失败。 typically the error I get is:
通常我得到的错误是:
can not read an implicit mapping pair;
无法读取隐式映射对; a colon is missed at line X, column Y:\n
X 行 Y 列缺少一个冒号:\n
what is the best way to parse the Yaml which has some key/values in the above format?解析具有上述格式的一些键/值的 Yaml 的最佳方法是什么?
{
is a special character in YAML which starts a flow sequence. {
是 YAML 中的一个特殊字符,它启动一个流序列。 You need to either quote the scalar that contains it:您需要引用包含它的标量:
key: "{{ val1 }} {{ val2 }}"
or use block scalars:或使用块标量:
key: >-
{{ val1 }} {{ val2 }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.