Improving docs

This commit is contained in:
Mike Farah 2022-08-01 14:12:35 +10:00
parent 6dfef716d7
commit a91a8ccc66
4 changed files with 10 additions and 12 deletions

View File

@ -9,12 +9,12 @@ These operators are useful to process yaml documents that have stringified embed
| Format | Decode (from string) | Encode (to string) | | Format | Decode (from string) | Encode (to string) |
| --- | -- | --| | --- | -- | --|
| Yaml | from_yaml | to_yaml(i)/@yaml | | Yaml | from_yaml/@yamld | to_yaml(i)/@yaml |
| JSON | from_json | to_json(i)/@json | | JSON | from_json/@jsond | to_json(i)/@json |
| Properties | from_props/@propsd | to_props/@props | | Properties | from_props/@propsd | to_props/@props |
| CSV | from_csv/@csvd | to_csv/@csv | | CSV | from_csv/@csvd | to_csv/@csv |
| TSV | from_tsv/@tsvd | to_tsv/@tsv | | 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 | | Base64 | @base64d | @base64 |

View File

@ -9,12 +9,12 @@ These operators are useful to process yaml documents that have stringified embed
| Format | Decode (from string) | Encode (to string) | | Format | Decode (from string) | Encode (to string) |
| --- | -- | --| | --- | -- | --|
| Yaml | from_yaml | to_yaml(i)/@yaml | | Yaml | from_yaml/@yamld | to_yaml(i)/@yaml |
| JSON | from_json | to_json(i)/@json | | JSON | from_json/@jsond | to_json(i)/@json |
| Properties | from_props/@propsd | to_props/@props | | Properties | from_props/@propsd | to_props/@props |
| CSV | from_csv/@csvd | to_csv/@csv | | CSV | from_csv/@csvd | to_csv/@csv |
| TSV | from_tsv/@tsvd | to_tsv/@tsv | | 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 | | Base64 | @base64d | @base64 |

View File

@ -1,10 +1,9 @@
# JSON # 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" %} {% hint style="warning" %}
Note that versions prior to 4.18 require the 'eval/e' command to be specified.  Note that versions prior to 4.18 require the 'eval/e' command to be specified. 

View File

@ -1,7 +1,6 @@
# JSON # 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.