Skip to content

JSON in YAML gets collapsed into a single line #265

Description

@MalteMagnussen

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

-    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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions