Skip to content

JSON.pretty_generate generates wrong format json output to MRI for at least an empty hash version 9.4.0.0 #515

@tqtu

Description

@tqtu

Code:

require 'json'
puts "With empty hash"
puts JSON.pretty_generate({})
puts "With empty hash in child"
puts JSON.pretty_generate({"empty": {}})

Output: jruby -v hello.rb

jruby 9.4.0.0 (3.1.0) 2022-11-23 95c0ec159f Java HotSpot(TM) 64-Bit Server VM 25.202-b08 on 1.8.0_202-b08 +jit [x86_64-darwin]
With empty hash
{
}
With empty hash in child
{
  "empty": {
}
}

The indentation is incorrect.
CC: @headius

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions