1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Removed redundant code, updated doc w.r.t reading json files

This commit is contained in:
Mike Farah
2017-04-19 15:45:45 +10:00
parent c2000a446b
commit ec25886528
16 changed files with 114 additions and 113 deletions

View File

@@ -1,5 +1,40 @@
### Yaml2json
### Yaml to Json
To convert output to json, use the --tojson (or -j) flag. This can be used with any command.
### json2yaml
To read in json, use the --fromjson (or -J) flag. This can be used with any command.
Given a sample.yaml file of:
```yaml
b:
c: 2
```
then
```bash
yaml r -j sample.yaml b.c
```
will output
```json
{"b":{"c":2}}
```
### Json to Yaml
To read in json, just pass in a json file instead of yaml, it will just work :)
e.g given a json file
```json
{"a":"Easy! as one two three","b":{"c":2,"d":[3,4]}}
```
then
```bash
yaml r sample.json
```
will output
```yaml
a: Easy! as one two three
b:
c: 2
d:
- 3
- 4
```

View File

@@ -1,7 +1,9 @@
```
yaml r <yaml file> <path>
yaml r <yaml_file|json_file> <path>
```
{!snippets/works_with_json.md!}
### Basic
Given a sample.yaml file of:
```yaml

View File

@@ -0,0 +1 @@
This command can take a json file as input too, and will output yaml unless specified to export as json (-j)

View File

@@ -1,6 +1,7 @@
```
yaml w <yaml file> <path> <new value>
yaml w <yaml_file|json_file> <path> <new value>
```
{!snippets/works_with_json.md!}
### To Stdout
Given a sample.yaml file of: