clj-yaml
clj-yaml copied to clipboard
Support multiple yaml documents in the same file
Hello,
How can I read multiple yaml documents from a single file ? Is that supported?
In yaml, you can write multiple documents in a single file by separating documents with a line that has only ---
In SnakeYaml, this is done using loadAll https://www.baeldung.com/java-snake-yaml#multiple-documents
Perhaps as a temporary workaround you can slurp the file, split it on #"^---$" and then use parse-string on each chunk.
I think we could have load-all variants of the functions we already have. E.g. parse-string-all.
Or: we could have an option :all true in which case it defers to the loadAll variants.
/cc @slipset @marcomorain
I'll defer to what @marcomorain has to say on this topic, as I'm not using, only maintaining this library.
@slipset @marcomorain FYI As this library is part of babashka, I wouldn't mind to get involved as a contributor to ensure this library is kept up to date.
I'd happily review a PR for this.
FWIW, adding a new-all vars would be my preferred approach, rather than adding options.
I would not want to a single load function that returns different types depending on the value of an optional argument – that makes reading and statically analysing the code much more difficult.
@marcomorain I agree!
Fixed by 7254f6189c7e07aa288c4fcc195bf9c9d4e68305