Skip to content

Commit

Permalink
[flori/json] Use rb_sym2str instead of SYM2ID
Browse files Browse the repository at this point in the history
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.

flori/json@5cbafb8dbe
  • Loading branch information
jhawthorn authored and hsbt committed Dec 25, 2023
1 parent 65ec74a commit ea5776e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/json/generator/generator.c
Expand Up @@ -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);
}
Expand Down

0 comments on commit ea5776e

Please sign in to comment.