Skip to content

Commit

Permalink
Improving docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed Aug 1, 2022
1 parent 6dfef71 commit a91a8cc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pkg/yqlib/doc/operators/encode-decode.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ These operators are useful to process yaml documents that have stringified embed

| Format | Decode (from string) | Encode (to string) |
| --- | -- | --|
| Yaml | from_yaml | to_yaml(i)/@yaml |
| JSON | from_json | to_json(i)/@json |
| Yaml | from_yaml/@yamld | to_yaml(i)/@yaml |
| JSON | from_json/@jsond | to_json(i)/@json |
| Properties | from_props/@propsd | to_props/@props |
| CSV | from_csv/@csvd | to_csv/@csv |
| TSV | from_tsv/@tsvd | to_tsv/@tsv |
| XML | from_xml | to_xml(i)/@xml |
| XML | from_xml/@xmld | to_xml(i)/@xml |
| Base64 | @base64d | @base64 |


Expand Down
6 changes: 3 additions & 3 deletions pkg/yqlib/doc/operators/headers/encode-decode.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ These operators are useful to process yaml documents that have stringified embed

| Format | Decode (from string) | Encode (to string) |
| --- | -- | --|
| Yaml | from_yaml | to_yaml(i)/@yaml |
| JSON | from_json | to_json(i)/@json |
| Yaml | from_yaml/@yamld | to_yaml(i)/@yaml |
| JSON | from_json/@jsond | to_json(i)/@json |
| Properties | from_props/@propsd | to_props/@props |
| CSV | from_csv/@csvd | to_csv/@csv |
| TSV | from_tsv/@tsvd | to_tsv/@tsv |
| XML | from_xml | to_xml(i)/@xml |
| XML | from_xml/@xmld | to_xml(i)/@xml |
| Base64 | @base64d | @base64 |


Expand Down
5 changes: 2 additions & 3 deletions pkg/yqlib/doc/usage/convert.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# JSON

Encode and decode to and from JSON. Note that, unless you have multiple JSON documents in a single file, YAML is a _superset_ of JSON - so `yq` can read any json file without doing anything special.
Encode and decode to and from JSON. Supports multiple JSON documents in a single file (e.g. NDJSON).

If you do have mulitple JSON documents in a single file (e.g. NDJSON) then you will need to explicity use the json parser `-p=json`.
Note that YAML is a superset of (single document) JSON - so you don't have to use the JSON parser to read JSON when there is only one JSON document in the input. You will probably want to pretty print the result in this case, to get idiomatic YAML styling.

This means you don't need to 'convert' a JSON file to YAML - however if you want idiomatic YAML styling, then you can use the `-P/--prettyPrint` flag, see examples below.

{% hint style="warning" %}
Note that versions prior to 4.18 require the 'eval/e' command to be specified. 
Expand Down
5 changes: 2 additions & 3 deletions pkg/yqlib/doc/usage/headers/convert.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# JSON

Encode and decode to and from JSON. Note that, unless you have multiple JSON documents in a single file, YAML is a _superset_ of JSON - so `yq` can read any json file without doing anything special.
Encode and decode to and from JSON. Supports multiple JSON documents in a single file (e.g. NDJSON).

If you do have mulitple JSON documents in a single file (e.g. NDJSON) then you will need to explicity use the json parser `-p=json`.
Note that YAML is a superset of (single document) JSON - so you don't have to use the JSON parser to read JSON when there is only one JSON document in the input. You will probably want to pretty print the result in this case, to get idiomatic YAML styling.

This means you don't need to 'convert' a JSON file to YAML - however if you want idiomatic YAML styling, then you can use the `-P/--prettyPrint` flag, see examples below.

0 comments on commit a91a8cc

Please sign in to comment.