json icon indicating copy to clipboard operation
json copied to clipboard

symbolize_names is a confusing method name

Open CodingAnarchy opened this issue 6 years ago • 1 comments

The symbolize_names option is confusing and out of sync with the rest of the Ruby standard library. For instance, the Hash class uses symbolize_keys as a method. It seems that "name" is only used in JSON documentation (where things are referred to as "name-value" pairs instead of "key-value" pairs). This is, I believe, intended to indicate that the key has to be a string, but when dealing with Ruby parsing it is confusing to remember that only the JSON library has a different name.

Is there any way we can add an alias to the option as symbolize_keys?

CodingAnarchy avatar Jan 10 '19 17:01 CodingAnarchy

As a side note, YAML also calls it symbolize_names, so probably YAML (Psych) would also need to be updated.

YAML.safe_load(data,symbolize_names: true)

So at the very least, JSON and YAML (for symbolize_names) are consistent with each other.

esotericpig avatar Jun 08 '21 19:06 esotericpig