Currently, I am utilizing npm's YAML parser to convert YAML into an object. However, instead of getting an array, I am receiving a group of named objects. This issue arises from the absence of dashes preceding the objects.
How can I transform this group of named objects into an array or instruct the parser to interpret it as such?
The sample Yaml snippet:
jobs:
job-a:
property-1: value
job-b:
property-1: different value
When using
const parsed = YAML.parse(content)
, the resulting object resembles the following JSON representation:
object.jobs = {
"job-a": { "property-1": "value"},
"job-b": { "property-1": ""different value"}
}
Instead of receiving an array that is easily iterable, I get properties like "job-a" and "job-b" within the jobs object.
I have reviewed the documentation but it mainly focuses on setting up YAML rather than addressing my specific issue. Any guidance on how to resolve this would be greatly appreciated.