Alex Klimashevsky
Alex Klimashevsky

Reputation: 2495

How to define yaml sequence mapping serialization styles?

There are 2 variants of list to mapping in yaml:

-
  name: Mark McGwire
  hr:   65
  avg:  0.278

and

- name: Mark McGwire
  hr:   65
  avg:  0.278

How do define this difference for serialization?

Upvotes: 0

Views: 118

Answers (1)

flyx
flyx

Reputation: 39738

The YAML spec calls the second form compact notation. There is no semantic difference. An implementation is not required to let you choose between the two representations.

The only implementation I know of that lets you choose between these representations is ruamel via yaml.compact(), see here.

Upvotes: 1

Related Questions