mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-24 22:58:10 +00:00
v4.35.2
This commit is contained in:
parent
4a36926788
commit
b06ab987b1
@ -29,7 +29,7 @@ It pipes the current, lets call it 'root' context through the `lhs` expression o
|
|||||||
cat
|
cat
|
||||||
```
|
```
|
||||||
|
|
||||||
Sidenote: this node holds not only its value 'cat', but comments and metadata too, including path and parent information.
|
Side note: this node holds not only its value 'cat', but comments and metadata too, including path and parent information.
|
||||||
|
|
||||||
The `=` operator then pipes the 'root' context through the `rhs` expression of `.b` to return the node
|
The `=` operator then pipes the 'root' context through the `rhs` expression of `.b` to return the node
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ will output
|
|||||||
bar: 100
|
bar: 100
|
||||||
```
|
```
|
||||||
|
|
||||||
## Group by field, with nuls
|
## Group by field, with nulls
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
- cat: dog
|
- cat: dog
|
||||||
|
@ -13,7 +13,7 @@ myMap:
|
|||||||
cat: meow
|
cat: meow
|
||||||
dog: bark
|
dog: bark
|
||||||
thing: hamster
|
thing: hamster
|
||||||
hamster: squeek
|
hamster: squeak
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
@ -22,7 +22,7 @@ yq '.myMap |= pick(["hamster", "cat", "goat"])' sample.yml
|
|||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
myMap:
|
myMap:
|
||||||
hamster: squeek
|
hamster: squeak
|
||||||
cat: meow
|
cat: meow
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Encode/Decode/Roundtrip CSV and TSV files.
|
Encode/Decode/Roundtrip CSV and TSV files.
|
||||||
|
|
||||||
## Encode
|
## Encode
|
||||||
Currently supports arrays of homogenous flat objects, that is: no nesting and it assumes the _first_ object has all the keys required:
|
Currently supports arrays of homogeneous flat objects, that is: no nesting and it assumes the _first_ object has all the keys required:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Bobo
|
- name: Bobo
|
||||||
|
@ -34,7 +34,7 @@ Given a sample.yml file of:
|
|||||||
ascii_=_symbols: replaced with _
|
ascii_=_symbols: replaced with _
|
||||||
"ascii_ _controls": dropped (this example uses \t)
|
"ascii_ _controls": dropped (this example uses \t)
|
||||||
nonascii_א_characters: dropped
|
nonascii_א_characters: dropped
|
||||||
effrot_expeñded_tò_preserve_accented_latin_letters: moderate (via unicode NFKD)
|
effort_expeñded_tò_preserve_accented_latin_letters: moderate (via unicode NFKD)
|
||||||
|
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
@ -46,7 +46,7 @@ will output
|
|||||||
ascii___symbols='replaced with _'
|
ascii___symbols='replaced with _'
|
||||||
ascii__controls='dropped (this example uses \t)'
|
ascii__controls='dropped (this example uses \t)'
|
||||||
nonascii__characters=dropped
|
nonascii__characters=dropped
|
||||||
effrot_expended_to_preserve_accented_latin_letters='moderate (via unicode NFKD)'
|
effort_expended_to_preserve_accented_latin_letters='moderate (via unicode NFKD)'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Encode shell variables: empty values, arrays and maps
|
## Encode shell variables: empty values, arrays and maps
|
||||||
|
19
usage/xml.md
19
usage/xml.md
@ -128,6 +128,25 @@ zoo:
|
|||||||
- cat
|
- cat
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Parse xml: force all as an array
|
||||||
|
Because of the way yq works, when updating everything you need to update the children before the parents. By default `..` will match parents first, so we reverse that before updating.
|
||||||
|
|
||||||
|
Given a sample.xml file of:
|
||||||
|
```xml
|
||||||
|
<zoo><thing><frog>boing</frog></thing></zoo>
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq -oy '([..] | reverse | .[]) |= [] + .' sample.xml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- zoo:
|
||||||
|
- thing:
|
||||||
|
- frog:
|
||||||
|
- boing
|
||||||
|
```
|
||||||
|
|
||||||
## Parse xml: attributes
|
## Parse xml: attributes
|
||||||
Attributes are converted to fields, with the default attribute prefix '+'. Use '--xml-attribute-prefix` to set your own.
|
Attributes are converted to fields, with the default attribute prefix '+'. Use '--xml-attribute-prefix` to set your own.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user