toml: add convenience convertion of Doc to map[string]toml.Any (#12473)

pull/12474/head
Larpon 2021-11-15 18:00:09 +01:00 committed by GitHub
parent c28041cecc
commit 7b9cca7524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -89,6 +89,12 @@ pub fn (d Doc) to_json() string {
return d.ast.to_json()
}
// to_any converts the `Doc` to toml.Any type.
pub fn (d Doc) to_any() Any {
values := d.ast.table as map[string]ast.Value
return d.ast_to_any(values)
}
// value queries a value from the TOML document.
// `key` should be in "dotted" form (`a.b.c`).
// `key` supports quoted keys like `a."b.c"`.