1

This yaml work:

-
  test: >
    long

This yaml does not:

-
  test: >
    long
test
text

This does not work:

-
  test: >
    "long
test
text"

How can I make it multiple lines? The question has been answered before but not on a sub level I think.

Do I have to indent the last rows?

I use this service to test it: http://yaml-online-parser.appspot.com/

Jens Törnell
  • 23,180
  • 45
  • 124
  • 206
  • Indent those following lines I think... http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines – Matt Hall Apr 08 '16 at 13:16

2 Answers2

2

Yes you need to indent follow up lines for your folded scalars with at least the same indentation as the parent line:

-
  test: >
    long
    test
    text

This has nothing to do with this being a sub level or not, this applies to folded (and literal) scalars at any level. For the folding it doesn't make much of a difference, but for literal style the leading spaces are removed with the same indentation as the top line (unless you specify an extra indent offset).

The less indented line ends the folded scalar, and at that point you need to start a new sequence entry (with -), but you have scalar there, test, resulting in an error.

Anthon
  • 69,918
  • 32
  • 186
  • 246
1

This works for me:

- yaml: 
  - >
    This is some long text
    that spans multiple lines.

Gives...

[
  {
    "yaml": [
      "This is some long text that spans multiple lines.\n"
    ]
  }
]
Matt Hall
  • 7,614
  • 1
  • 23
  • 36