* [ruby-core:91115] [Ruby trunk Feature#15541] Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
[not found] <redmine.issue-15541.20190116014456@ruby-lang.org>
@ 2019-01-16 1:44 ` keystonelemur
2019-01-16 2:04 ` [ruby-core:91116] " shevegen
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: keystonelemur @ 2019-01-16 1:44 UTC (permalink / raw)
To: ruby-core
Issue #15541 has been reported by baweaver (Brandon Weaver).
----------------------------------------
Feature #15541: Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
https://bugs.ruby-lang.org/issues/15541
* Author: baweaver (Brandon Weaver)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
https://github.com/ruby/psych/issues/341
When trying to symbolize keys on JSON parsing, it's really hard to remember the name `symbolize_names`:
```
JSON.parse(data, symbolize_names: true)
```
I would like to propose that we change this keyword to `symbolize_keys` to be more clear:
```
JSON.parse(data, symbolize_keys: true)
```
The documentation for this method also reflects the confusion: http://ruby-doc.org/stdlib-2.6/libdoc/json/rdoc/JSON.html#method-i-parse-21
```
symbolize_names: If set to true, returns symbols for the names (keys) in a JSON object. Otherwise strings are returned. Strings are the default.
```
The same issue came up in Psych not too long ago:
https://github.com/ruby/psych/issues/341
I believe the current name causes confusion. Would it be possible to add an alias to this keyword for clarity?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:91116] [Ruby trunk Feature#15541] Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
[not found] <redmine.issue-15541.20190116014456@ruby-lang.org>
2019-01-16 1:44 ` [ruby-core:91115] [Ruby trunk Feature#15541] Add alias symbolize_keys for symbolize_names kwarg for JSON.parse keystonelemur
@ 2019-01-16 2:04 ` shevegen
2019-01-23 17:10 ` [ruby-core:91233] " keystonelemur
2020-01-15 19:00 ` [ruby-core:96873] [Ruby master " justin
3 siblings, 0 replies; 4+ messages in thread
From: shevegen @ 2019-01-16 2:04 UTC (permalink / raw)
To: ruby-core
Issue #15541 has been updated by shevegen (Robert A. Heiler).
Personally I think that alias name would make sense. With a new alias the backwards
behaviour would also be retained.
----------------------------------------
Feature #15541: Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
https://bugs.ruby-lang.org/issues/15541#change-76349
* Author: baweaver (Brandon Weaver)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
https://github.com/ruby/psych/issues/341
When trying to symbolize keys on JSON parsing, it's really hard to remember the name `symbolize_names`:
```
JSON.parse(data, symbolize_names: true)
```
I would like to propose that we change this keyword to `symbolize_keys` to be more clear:
```
JSON.parse(data, symbolize_keys: true)
```
The documentation for this method also reflects the confusion: http://ruby-doc.org/stdlib-2.6/libdoc/json/rdoc/JSON.html#method-i-parse-21
```
symbolize_names: If set to true, returns symbols for the names (keys) in a JSON object. Otherwise strings are returned. Strings are the default.
```
The same issue came up in Psych not too long ago:
https://github.com/ruby/psych/issues/341
I believe the current name causes confusion. Would it be possible to add an alias to this keyword for clarity?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:91233] [Ruby trunk Feature#15541] Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
[not found] <redmine.issue-15541.20190116014456@ruby-lang.org>
2019-01-16 1:44 ` [ruby-core:91115] [Ruby trunk Feature#15541] Add alias symbolize_keys for symbolize_names kwarg for JSON.parse keystonelemur
2019-01-16 2:04 ` [ruby-core:91116] " shevegen
@ 2019-01-23 17:10 ` keystonelemur
2020-01-15 19:00 ` [ruby-core:96873] [Ruby master " justin
3 siblings, 0 replies; 4+ messages in thread
From: keystonelemur @ 2019-01-23 17:10 UTC (permalink / raw)
To: ruby-core
Issue #15541 has been updated by baweaver (Brandon Weaver).
shevegen (Robert A. Heiler) wrote:
> Personally I think that alias name would make sense. With a new alias the backwards
> behaviour would also be retained.
An alias would probably be best as otherwise it would cause breaking changes, and I think we'd rather avoid that.
----------------------------------------
Feature #15541: Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
https://bugs.ruby-lang.org/issues/15541#change-76479
* Author: baweaver (Brandon Weaver)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
https://github.com/ruby/psych/issues/341
When trying to symbolize keys on JSON parsing, it's really hard to remember the name `symbolize_names`:
```
JSON.parse(data, symbolize_names: true)
```
I would like to propose that we change this keyword to `symbolize_keys` to be more clear:
```
JSON.parse(data, symbolize_keys: true)
```
The documentation for this method also reflects the confusion: http://ruby-doc.org/stdlib-2.6/libdoc/json/rdoc/JSON.html#method-i-parse-21
```
symbolize_names: If set to true, returns symbols for the names (keys) in a JSON object. Otherwise strings are returned. Strings are the default.
```
The same issue came up in Psych not too long ago:
https://github.com/ruby/psych/issues/341
I believe the current name causes confusion. Would it be possible to add an alias to this keyword for clarity?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:96873] [Ruby master Feature#15541] Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
[not found] <redmine.issue-15541.20190116014456@ruby-lang.org>
` (2 preceding siblings ...)
2019-01-23 17:10 ` [ruby-core:91233] " keystonelemur
@ 2020-01-15 19:00 ` justin
3 siblings, 0 replies; 4+ messages in thread
From: justin @ 2020-01-15 19:00 UTC (permalink / raw)
To: ruby-core
Issue #15541 has been updated by jsc (Justin Collins).
This would be a nice simple addition, as I have gotten this wrong several times. `JSON.parse` does not raise any error when the wrong option name is given, so you only notice when trying to retrieve values with symbol keys returns `nil`. After some debugging you might realize the keys are still strings.
Note that MultiJson uses `symbolize_keys`: https://www.rubydoc.info/gems/multi_json/MultiJson#load-instance_method which may be where some confusion is coming from.
----------------------------------------
Feature #15541: Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
https://bugs.ruby-lang.org/issues/15541#change-83884
* Author: baweaver (Brandon Weaver)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
https://github.com/ruby/psych/issues/341
When trying to symbolize keys on JSON parsing, it's really hard to remember the name `symbolize_names`:
```
JSON.parse(data, symbolize_names: true)
```
I would like to propose that we change this keyword to `symbolize_keys` to be more clear:
```
JSON.parse(data, symbolize_keys: true)
```
The documentation for this method also reflects the confusion: http://ruby-doc.org/stdlib-2.6/libdoc/json/rdoc/JSON.html#method-i-parse-21
```
symbolize_names: If set to true, returns symbols for the names (keys) in a JSON object. Otherwise strings are returned. Strings are the default.
```
The same issue came up in Psych not too long ago:
https://github.com/ruby/psych/issues/341
I believe the current name causes confusion. Would it be possible to add an alias to this keyword for clarity?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-15 19:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-15541.20190116014456@ruby-lang.org>
2019-01-16 1:44 ` [ruby-core:91115] [Ruby trunk Feature#15541] Add alias symbolize_keys for symbolize_names kwarg for JSON.parse keystonelemur
2019-01-16 2:04 ` [ruby-core:91116] " shevegen
2019-01-23 17:10 ` [ruby-core:91233] " keystonelemur
2020-01-15 19:00 ` [ruby-core:96873] [Ruby master " justin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).