I'm trying to parse a YAML file within Google Apps Script. I would like to use the information from a YAML file in Google Sheets.
From what I understood, the underlying library is available (
Then you can convert your yaml string into a json object this way:
// your YAML sting
var string =
`foo: bar
stuff:
foo: bar
bar: foo
arr:
- aaa
- bbb
- ccc
`
// JSON object
var obj = YAML.eval(string);
console.log(JSON.stringify(obj))
Output:
{
"foo": "bar",
"stuff": {
"foo": "bar",
"bar": "foo"
},
"arr": ["aaa", "bbb", "ccc"]
}