-
Notifications
You must be signed in to change notification settings - Fork 352
Closed
Description
Using:
ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [arm64-darwin23]
Test script:
require "json"
require "uri"
test = {
a: {
b: URI("https://example.com"),
},
c: "d",
}
puts JSON.pretty_generate(test)
Output with 2.10.2:
$ cat Gemfile
source "https://rubygems.org"
gem "json", "=2.10.2"
$ bundle exec ruby test.rb
{
"a": {
"b": "https://example.com"
},
"c": "d"
}
Output with 2.11.2:
$ cat Gemfile
source "https://rubygems.org"
gem "json", "=2.11.2"
$ bundle exec ruby test.rb
{
"a": {
"b": "https://example.com"
},
"c": "d"
}
Above example was trying to give a real-world use case (URIs). A simpler example for an rspec would be something like:
require "json"
class A
def to_s = "value"
end
test = {
a: {
b: A.new,
},
c: "d",
}
puts JSON.pretty_generate(test)
$ bundle exec ruby test.rb
{
"a": {
"b": "value"
},
"c": "d"
}
p-linnane
Metadata
Metadata
Assignees
Labels
No labels