JSON in YAML gets collapsed into a single line
- Dominant language
- Go
- Stars
- 1.8k
- Forks
- 75
- PR merge metrics
- No merged PRs in 30d
Description
yamlfmt just collapses json into a single line.
Preferably I would like yamlfmt to convert the json into yaml.
But if that is not possible, I'd like it to just not touch the json.
Collapsing it into a single line is definitely NOT what I want. And I cannot see a setting to change it in [the docs](https://github.com/google/yamlfmt/blob/main/docs/config-file.md#basic-formatter)
```diff
- attributes: {
- "redacted": {
- "redacted" : "redacted",
- "letsencrypt": {
- "db_name" : "redacted",
- "db_user": "redacted",
- "db_server": "redacted",
- "nginx_acl" : ["redacted"]
- }
- },
- "linux_gateway": {
- "macros": {
- "hosts": {
- "webcaches": "redacted",
- }
- }
- },
- "firewall": {
- "macros-v4": {
- "webcaches": "redacted",
- }
- },
- "secrets": {
- "redacted": {
- "redacted": {
- "cipher": "redacted",
- "encrypted_data": "redacted"
- },
- },
- "redacted": {
- "private-key": {
- "cipher": "redacted",
- "encrypted_data": "redacted"
- },
- "meta": {
- "cipher": "redacted",
- "encrypted_data": "redacted"
- },
- "regr": {
- "cipher": "redacted",
- "encrypted_data": "redacted"
- }
- }
- }
- }
+ attributes: {"redacted": {"redacted": "redacted", "redacted": {"db_name": "redacted", "db_user": "redacted", "db_server": "redacted", "nginx_acl": ["redacted"]}}, "linux_gateway": {"macros": {"hosts": {"webcaches": "redacted"}}}, "firewall": {"macros-v4": {"webcaches": "redacted"}}, "secrets": {"postgresql": {"redacted": {"cipher": "redacted", "encrypted_data": "redacted"}}, "letsencrypt": {"private-key": {"cipher": "redacted", "encrypted_data": "redacted"}, "meta": {"cipher": "redacted", "encrypted_data": "redacted"}, "regr": {"cipher": "redacted", "encrypted_data": "redacted"}}}}
```
Context: I am using [multi-gitter](https://github.com/lindell/multi-gitter) to run `yamlfmt` across 100+ repos in the company. I don't know why some people would put json into their yaml, but it sadly exists.
Currently I have to Reject any changes done to repos that nest json in their yaml, because people (understandably) DON'T want their json in the yaml to get squished into a single line.
Contributor guide
Assessment
This issue has not been assessed yet.