Skip to content

Commit 3b473ff

Browse files
etiennebarriebyroot
authored andcommitted
Don't emit deprecation warnings in State#to_h in TruffleRuby
$ ruby -Ilib -rjson -W:deprecated -e JSON::State.new.to_h |& uniq -c 13 -e:1: warning: JSON::State#[] is deprecated and will be removed in json 3.0.0
1 parent 256cad5 commit 3b473ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/json/truffle_ruby/generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ def allow_duplicate_key? # :nodoc:
312312
def to_h
313313
result = {}
314314
instance_variables.each do |iv|
315-
iv = iv.to_s[1..-1]
316-
result[iv.to_sym] = self[iv]
315+
key = iv.to_s[1..-1]
316+
result[key.to_sym] = instance_variable_get(iv)
317317
end
318318

319319
if result[:allow_duplicate_key].nil?

0 commit comments

Comments
 (0)