-
Is this expected behavior? // when
stringify({arr: [1, 2]})
// returns: 'arr:\n - 1\n - 2\n'
// when
stringify({arr: []})
// returns: 'arr: []\n' I was expecting blank array to be Also, how can I omit blank array fields? |
Beta Was this translation helpful? Give feedback.
Answered by
eemeli
Jun 22, 2023
Replies: 1 comment
-
To get what you want, I'd recommend using a replacer to replace empty arrays with |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
namantam1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[]
is the only available YAML representation of an empty array. The empty value you're expecting represents a null value.To get what you want, I'd recommend using a replacer to replace empty arrays with
undefined
, which is ignored: https://eemeli.org/yaml/#yaml-stringify