Decoder Properties

This commit is contained in:
Mike Farah
2022-02-09 13:16:59 +11:00
parent 4d4bd5114d
commit a5ab9a8a0a
7 changed files with 214 additions and 16 deletions
+28 -3
View File
@@ -27,7 +27,7 @@ emptyMap: []
```
then
```bash
yq -o=props -I=0 '.' sample.yml
yq -o=props sample.yml
```
will output
```properties
@@ -54,7 +54,7 @@ emptyMap: []
```
then
```bash
yq -o=props -I=0 '... comments = ""' sample.yml
yq -o=props '... comments = ""' sample.yml
```
will output
```properties
@@ -80,7 +80,7 @@ emptyMap: []
```
then
```bash
yq -o=props -I=0 '(.. | select( (tag == "!!map" or tag =="!!seq") and length == 0)) = ""' sample.yml
yq -o=props '(.. | select( (tag == "!!map" or tag =="!!seq") and length == 0)) = ""' sample.yml
```
will output
```properties
@@ -94,3 +94,28 @@ emptyArray =
emptyMap =
```
## Decode properties
Given a sample.properties file of:
```properties
# comments on values appear
person.name = Mike
# comments on array values appear
person.pets.0 = cat
person.food.0 = pizza
```
then
```bash
yq -p=props sample.properties
```
will output
```yaml
person:
name: Mike # comments on values appear
pets:
- cat # comments on array values appear
food:
- pizza
```