tj / js-yaml

CommonJS YAML Parser -- fast, elegant and tiny yaml parser for javascript
276 stars 41 forks source link

empty array causes extra layer of nesting #43

Open coolaj86 opened 12 years ago

coolaj86 commented 12 years ago

Unexpected Nesting


---
  - "baz"
  - "qux"
  - "quxx"
  - null
  - true
  - 
    foo: "bar"
    corge: null
    grault: 1
    garply: true
    waldo: "false"
    fred: "undefined"
  - 42
  - 
  - 
    - "hello"
    - "world"

and becomes

[
  "baz",
  "qux",
  "quxx",
  null,
  true,
  {
    "foo": "bar",
    "corge": null,
    "grault": 1,
    "garply": true,
    "waldo": "false",
    "fred": "undefined"
  },
  42,
  [
    [
      "hello",
      "world"
    ]
  ]
]

Expected Behavior


---
  - "baz"
  - "qux"
  - "quxx"
  - null
  - true
  - 
    foo: "bar"
    corge: null
    grault: 1
    garply: true
    waldo: "false"
    fred: "undefined"
  - 
    - "hello"
    - "world"
  - 42
  - 

and becomes

[
  "baz",
  "qux",
  "quxx",
  null,
  true,
  {
    "foo": "bar",
    "corge": null,
    "grault": 1,
    "garply": true,
    "waldo": "false",
    "fred": "undefined"
  },
  [
    "hello",
    "world"
  ],
  42,
  null
]