mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
1.8 KiB
1.8 KiB
The style operator can be used to get or set the style of nodes (e.g. string style, yaml style)
Set tagged style
Given a sample.yml file of:
a: cat
b: 5
c: 3.2
e: true
'': null
then
yq eval '.. style="tagged"' sample.yml
will output
!!map
a: cat
b: 5
c: 3.2
e: true
'': !!null null
Set double quote style
Given a sample.yml file of:
a: cat
b: 5
c: 3.2
e: true
'': null
then
yq eval '.. style="double"' sample.yml
will output
a: cat
b: 5
c: 3.2
e: true
'': "null"
Set single quote style
Given a sample.yml file of:
a: cat
b: 5
c: 3.2
e: true
'': null
then
yq eval '.. style="single"' sample.yml
will output
a: cat
b: 5
c: 3.2
e: true
'': 'null'
Set literal quote style
Given a sample.yml file of:
a: cat
b: 5
c: 3.2
e: true
'': null
then
yq eval '.. style="literal"' sample.yml
will output
a: cat
b: 5
c: 3.2
e: true
'': |-
null
Set folded quote style
Given a sample.yml file of:
a: cat
b: 5
c: 3.2
e: true
'': null
then
yq eval '.. style="folded"' sample.yml
will output
a: cat
b: 5
c: 3.2
e: true
'': >-
null
Set flow quote style
Given a sample.yml file of:
a: cat
b: 5
c: 3.2
e: true
'': null
then
yq eval '.. style="flow"' sample.yml
will output
{a: cat, b: 5, c: 3.2, e: true, '': null}
Pretty print
Set empty (default) quote style
Given a sample.yml file of:
a: cat
b: 5
c: 3.2
e: true
'': null
then
yq eval '.. style=""' sample.yml
will output
a: cat
b: 5
c: 3.2
e: true
'': null
Read style
Given a sample.yml file of:
{a: "cat", b: 'thing'}
then
yq eval '.. | style' sample.yml
will output
flow