[ruby/json] Deprecate Kernel#j and Kernel#jj
https://github.com/ruby/json/commit/27155b6500
This commit is contained in:
parent
1afc539900
commit
26a9ccbf83
@ -1005,6 +1005,12 @@ module ::Kernel
|
|||||||
# Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
|
# Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
|
||||||
# one line.
|
# one line.
|
||||||
def j(*objs)
|
def j(*objs)
|
||||||
|
if RUBY_VERSION >= "3.0"
|
||||||
|
warn "Kernel#j is deprecated and will be removed in json 3.0.0", uplevel: 1, category: :deprecated
|
||||||
|
else
|
||||||
|
warn "Kernel#j is deprecated and will be removed in json 3.0.0", uplevel: 1
|
||||||
|
end
|
||||||
|
|
||||||
objs.each do |obj|
|
objs.each do |obj|
|
||||||
puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
|
puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
|
||||||
end
|
end
|
||||||
@ -1014,6 +1020,12 @@ module ::Kernel
|
|||||||
# Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
|
# Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
|
||||||
# indentation and over many lines.
|
# indentation and over many lines.
|
||||||
def jj(*objs)
|
def jj(*objs)
|
||||||
|
if RUBY_VERSION >= "3.0"
|
||||||
|
warn "Kernel#jj is deprecated and will be removed in json 3.0.0", uplevel: 1, category: :deprecated
|
||||||
|
else
|
||||||
|
warn "Kernel#jj is deprecated and will be removed in json 3.0.0", uplevel: 1
|
||||||
|
end
|
||||||
|
|
||||||
objs.each do |obj|
|
objs.each do |obj|
|
||||||
puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
|
puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user