jeremyfa / yaml.js

Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Format array of objects

YarovoiVadym opened this issue · comments

This object:

[
    {
        name: 'name',
        value: 'value'
    },
    {
        name: 'name',
        value: 'value'
    },
    {
        name: 'name',
        valueFrom: {
            name: 'value',
            key: ''
        }
    }
]

After YAML.stringify I expect this:

- name: name
  value: value
- name: name
  value: value
- name: name
  valueFrom:
      name: value
      key: ""

but instead of expected result I get this:

-
   name: name
   value: value
-
   name: name
   value: value
-
   name: name
   valueFrom:
     name: value
     key: ""

It's not right YAML formatting

@jeremyfa Any chance that these issues are still being looked at in terms of fixes/work arounds? Cheers!

Hi, unfortunately I didn't have much time to take a look at it yet, but I agree that it should be fixed!

@jeremyfa Thanks for getting back to me! I'll keep my eyes on this project for a fix in the future, it would be super helpful for a step in a project I'm working on. Cheers!

@joshdrink Hi, in a project I'm working on, I have used this RegEx for a temporary fix of this issue:
data.replace(/(\s+\-)\s*\n\s+/g, '$1 ');
Maybe it will be helpful to you.

@YarovoiVadym You're a life saver! This worked perfectly. :)