Closed fawaf closed 2 years ago
This is an expected feature, depending on your wrapping width. The default is 80
, for which that last value fits on one line. If you want to force it to always wrap, use wrap:true
, or a smaller width. For example:
require 'neatjson'
h = {a:{b:{c:{d:{e:{f:"deep"}}}}}}
JSON.neat_generate(h, after_colon:1, padding:1)
puts JSON.neat_generate(h, after_colon:1, padding:1)
#=> { "a": { "b": { "c": { "d": { "e": { "f": "deep" } } } } } }
puts JSON.neat_generate(h, after_colon:1, padding:1, wrap:40)
#=> {
#=> "a": {
#=> "b": {
#=> "c": { "d": { "e": { "f": "deep" } } }
#=> }
#=> }
#=> }
puts JSON.neat_generate(h, after_colon:1, padding:1, wrap:30)
#=> {
#=> "a": {
#=> "b": {
#=> "c": {
#=> "d": {
#=> "e": { "f": "deep" }
#=> }
#=> }
#=> }
#=> }
#=> }
puts JSON.neat_generate(h, after_colon:1, padding:1, wrap:true)
#=> {
#=> "a": {
#=> "b": {
#=> "c": {
#=> "d": {
#=> "e": {
#=> "f": "deep"
#=> }
#=> }
#=> }
#=> }
#=> }
#=> }
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:the expected output is: