mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-24 14:45:39 +00:00
Added property number example
This commit is contained in:
parent
31f8a80b5f
commit
450a4b4d37
@ -2,7 +2,7 @@
|
||||
|
||||
The slice array operator takes an array as input and returns a subarray. Like the `jq` equivalent, `.[10:15]` will return an array of length 5, starting from index 10 inclusive, up to index 15 exclusive. Negative numbers count backwards from the end of the array.
|
||||
|
||||
You may leave out the first or second number, which will will refer to the start or end of the array respectively.
|
||||
You may leave out the first or second number, which will refer to the start or end of the array respectively.
|
||||
|
||||
## Slicing arrays
|
||||
Given a sample.yml file of:
|
||||
|
@ -230,6 +230,23 @@ person:
|
||||
- pizza
|
||||
```
|
||||
|
||||
## Decode properties: numbers
|
||||
All values are assumed to be strings when parsing properties, but you can use the `from_yaml` operator on all the strings values to autoparse into the correct type.
|
||||
|
||||
Given a sample.properties file of:
|
||||
```properties
|
||||
a.b = 10
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq -p=props ' (.. | select(tag == "!!str")) |= from_yaml' sample.properties
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
a:
|
||||
b: 10
|
||||
```
|
||||
|
||||
## Decode properties - array should be a map
|
||||
If you have a numeric map key in your property files, use array_to_map to convert them to maps.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user