ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: shevegen@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:91116] [Ruby trunk Feature#15541] Add alias symbolize_keys for symbolize_names kwarg for JSON.parse
Date: Wed, 16 Jan 2019 02:04:47 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-76349.20190116020445.fc6e46e55fec3d23@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15541.20190116014456@ruby-lang.org

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/

  parent reply	other threads:[~2019-01-16  2:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
2019-01-23 17:10 ` [ruby-core:91233] " keystonelemur
2020-01-15 19:00 ` [ruby-core:96873] [Ruby master " justin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-76349.20190116020445.fc6e46e55fec3d23@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).