Skip to content

Document Add/Set/Delete values deep in the YAML? #355

Closed Answered by eemeli
5chrisalexander asked this question in Q&A
Discussion options

You must be logged in to vote

This should work, at least with yaml@next?

# src
a:
  b:
    c:
      key1: value1
import { parseDocument } from 'yaml'

const doc = parseDocument(src)
doc.setIn(['a','b','c','key2'], 'value2')
doc.setIn(['a','d','e','key3'], 'value3')
# doc.toString()
a:
  b:
    c:
      key1: value1
      key2: value2
  d:
    e:
      key3: value3

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@5chrisalexander
Comment options

Answer selected by 5chrisalexander
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants