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
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
|
@ -26,7 +26,7 @@ will output
|
||||
bar: 100
|
||||
```
|
||||
|
||||
## Group by field, with nuls
|
||||
## Group by field, with nulls
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
- cat: dog
|
||||
|
@ -13,7 +13,7 @@ myMap:
|
||||
cat: meow
|
||||
dog: bark
|
||||
thing: hamster
|
||||
hamster: squeek
|
||||
hamster: squeak
|
||||
```
|
||||
then
|
||||
```bash
|
||||
@ -22,7 +22,7 @@ yq '.myMap |= pick(["hamster", "cat", "goat"])' sample.yml
|
||||
will output
|
||||
```yaml
|
||||
myMap:
|
||||
hamster: squeek
|
||||
hamster: squeak
|
||||
cat: meow
|
||||
```
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
Encode/Decode/Roundtrip CSV and TSV files.
|
||||
|
||||
## 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
|
||||
- name: Bobo
|
||||
|
@ -34,7 +34,7 @@ Given a sample.yml file of:
|
||||
ascii_=_symbols: replaced with _
|
||||
"ascii_ _controls": dropped (this example uses \t)
|
||||
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
|
||||
@ -46,7 +46,7 @@ will output
|
||||
ascii___symbols='replaced with _'
|
||||
ascii__controls='dropped (this example uses \t)'
|
||||
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
|
||||
|
19
usage/xml.md
19
usage/xml.md
@ -128,6 +128,25 @@ zoo:
|
||||
- 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
|
||||
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