Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tqtu opened this issue Feb 6, 2023 · 4 comments · Fixed by #517

Comments

@tqtu
Copy link

tqtu commented Feb 6, 2023

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

@headius
Copy link
Contributor

headius commented Feb 6, 2023

Thank you for the report!

@headius
Copy link
Contributor

headius commented Feb 8, 2023

Likely caused by changes in #449.

headius added a commit to headius/json that referenced this issue Feb 8, 2023
@headius
Copy link
Contributor

headius commented Feb 8, 2023

Fix in #517.

@mrckzgl
Copy link

mrckzgl commented Mar 21, 2023

We experience the empty hash problem also with MRI ruby ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux] and jruby jruby 9.4.1.0 (3.1.0) 2023-02-07 237d5fa5f4 Java HotSpot(TM) 64-Bit Server VM 15.0.2+7-27 on 15.0.2+7-27 +jit [x86_64-linux] while using the json/pure variant. Should I open a new issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants