Working with TOML
Decode from TOML. Note that yq does not yet support outputting in TOML format (and therefore it cannot roundtrip)
Parse: Simple
Given a sample.toml file of:
A = "hello"
B = 12
then
yq -oy '.' sample.tomlwill output
A: hello
B: 12Parse: Deep paths
Given a sample.toml file of:
person.name = "hello"
person.address = "12 cat st"
then
yq -oy '.' sample.tomlwill output
person:
name: hello
address: 12 cat stEncode: Scalar
Given a sample.toml file of:
person.name = "hello"
person.address = "12 cat st"
then
yq '.person.name' sample.tomlwill output
helloParse: inline table
Given a sample.toml file of:
name = { first = "Tom", last = "Preston-Werner" }then
yq -oy '.' sample.tomlwill output
name:
first: Tom
last: Preston-WernerParse: Array Table
Given a sample.toml file of:
[owner.contact]
name = "Tom Preston-Werner"
age = 36
[[owner.addresses]]
street = "first street"
suburb = "ok"
[[owner.addresses]]
street = "second street"
suburb = "nice"
then
yq -oy '.' sample.tomlwill output
owner:
contact:
name: Tom Preston-Werner
age: 36
addresses:
- street: first street
suburb: ok
- street: second street
suburb: niceParse: Empty Table
Given a sample.toml file of:
[dependencies]
then
yq -oy '.' sample.tomlwill output
dependencies: {}Last updated
Was this helpful?