NeatJSON icon indicating copy to clipboard operation
NeatJSON copied to clipboard

neat formatting seems to ignore hash levels deeper than 2

Open fawaf opened this issue 5 years ago • 0 comments

the command to generate the below output is JSON.neat_generate(env, after_colon: 1, padding: 1). env contains the ruby hash object used to generate the output.

the output somehow has the _template hash all in one line, which is not expected:

{
  "name": "foo",
  "description": "some environment",
  "cookbook_versions": {
...snip...
    "seven_zip": "= 2.0.2",
    "windows": "= 1.39.1",
    "zookeeper": "= 9.0.1"
  },
  "json_class": "Chef::Environment",
  "chef_type": "environment",
  "default_attributes": {
    "blah": {
      "_template": { "elb_logs_index_template": { "settings": { "number_of_shards": 6 } } }
    }
  },
  "override_attributes": {}
}

the expected output is:

{
  "name": "foo",
  "description": "some environment",
  "cookbook_versions": {
...snip...
    "seven_zip": "= 2.0.2",
    "windows": "= 1.39.1",
    "zookeeper": "= 9.0.1"
  },
  "json_class": "Chef::Environment",
  "chef_type": "environment",
  "default_attributes": {
    "blah": {
      "_template": {
        "elb_logs_index_template": {
          "settings": {
            "number_of_shards": 6
          }
        }
      }
    }
  },
  "override_attributes": {}
}

fawaf avatar Sep 04 '20 20:09 fawaf