This commit is contained in:
Mike Farah
2026-08-19 15:23:47 +10:00
parent d51f1fad31
commit 718f66dfec
8 changed files with 61 additions and 45 deletions
+16
View File
@@ -125,6 +125,22 @@ will output
{"whatever":"cat"}
```
## Encode json: preserve floats with trailing zero
Whole-number floats keep their decimal point so downstream consumers see a JSON number with a fractional part (matches Go's encoding/json, Python's json, and jq).
Given a sample.yml file of:
```yaml
percentiles: [50.0, 95.0, 99.0, 99.9]
```
then
```bash
yq -o=json -I=0 '.' sample.yml
```
will output
```json
{"percentiles":[50.0,95.0,99.0,99.9]}
```
## Roundtrip JSON Lines / NDJSON
Given a sample.json file of:
```json
+1 -1
View File
@@ -1,6 +1,6 @@
# TOML
Decode from TOML. Note that `yq` does not yet support outputting in TOML format (and therefore it cannot roundtrip)
Encode and decode to and from TOML.
## Parse: Simple