parse
Last updated
Converts a string into a structured document at runtime.
parse(format, content)format (string) - The format to parse ("json", "yaml", "toml", etc).
content (string) - The string to parse.
Parse JSON and access a field
parse("json", '{"name":"Tom"}').name
// "Tom"Parse YAML
parse("yaml", "name: Tom\nage: 30").name
// "Tom"CLI usage — parse an embedded JSON string from a YAML file
$ echo 'config: {"port": 8080}' | dasel -i yaml 'parse("json", config).port'
8080Combined with readFile
Roundtrip with stringify
Last updated
parse("json", readFile("config.json")).database.hostparse("json", stringify("json", {"a": 1})).a
// 1