ptilloo
ptilloo

Reputation: 65

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 :

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

what is the best way to parse the Yaml which has some key/values in the above format?

Upvotes: 0

Views: 1298

Answers (1)

flyx
flyx

Reputation: 39708

{ is a special character in YAML which starts a flow sequence. You need to either quote the scalar that contains it:

key: "{{ val1 }} {{ val2 }}"

or use block scalars:

key: >-
  {{ val1 }} {{ val2 }}

Upvotes: 1

Related Questions