mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-02 15:14:52 +08:00
v4.35.2
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user