From ea5776e7e4262c915f7f8b8884af420dd87d769c Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 5 Dec 2023 13:44:28 -0800 Subject: [PATCH] [flori/json] Use rb_sym2str instead of SYM2ID This avoids pinning an id to the symbol used if a dynamic symbol is passed in as a hash key. rb_sym2str is available in Ruby 2.2+ and json depends on >= 2.3. https://github.com/flori/json/commit/5cbafb8dbe --- ext/json/generator/generator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c index a71acfbb765ef3..a33df848df638c 100644 --- a/ext/json/generator/generator.c +++ b/ext/json/generator/generator.c @@ -867,7 +867,7 @@ json_object_i(VALUE key, VALUE val, VALUE _arg) if (klass == rb_cString) { key_to_s = key; } else if (klass == rb_cSymbol) { - key_to_s = rb_id2str(SYM2ID(key)); + key_to_s = rb_sym2str(key); } else { key_to_s = rb_funcall(key, i_to_s, 0); }