3 ms·
First thing we could do here is rename the JSON.parse :symbolize_names keyword to :symbolize_keys -- always trips me up for some reason.
by ezekg 1y ago
First thing we could do here is rename the JSON.parse :symbolize_names keyword to :symbolize_keys -- always trips me up for some reason.
- athorax 1y agoWhy? JSON is name-value pairs https://www.json.org/json-en.html https://www.json.org/json-en.html
- ezekg 1y agoI guess I'm more thinking about Ruby/Rails conventions, e.g. methods like Hash#symbolize_keys. Mixing the two has always been a smell to me, but maybe you're right.
- caseyohara 1y agoSure, but JSON.parse returns a Hash, which is key-value pairs. The method argument is about the return value, not the input value, so it is more like "Parse this JSON, and symbolize the keys in the resulting Hash before returning it to me". Plus, as mentioned, symbolize_keys is more conventional.
- fuzzy_biscuit 1y agoMaybe it could just be an alias. People do also refer to them as key-value pairs, so that feels reasonable.
- deleted 1y ago[deleted]
- onli 1y agoBreaking the API like that would be extremely hostile and exactly the kind of churn byroot thankfully claimed he does not want to produce. If anything both options could be offered. Don't be disrespectful with developers time.