From 9675b48de6f271fa4fff481276f3d2da03276d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Sat, 22 Nov 2025 12:24:34 +0100 Subject: [PATCH] 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 --- lib/json/truffle_ruby/generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/json/truffle_ruby/generator.rb b/lib/json/truffle_ruby/generator.rb index dd79bab8..71a909dd 100644 --- a/lib/json/truffle_ruby/generator.rb +++ b/lib/json/truffle_ruby/generator.rb @@ -312,8 +312,8 @@ def allow_duplicate_key? # :nodoc: def to_h result = {} instance_variables.each do |iv| - iv = iv.to_s[1..-1] - result[iv.to_sym] = self[iv] + key = iv.to_s[1..-1] + result[key.to_sym] = instance_variable_get(iv) end if result[:allow_duplicate_key].nil?