Disable automatically added square brackets at end of array name
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start at the Unirest.post call and trace how the parameters hash serializes array values for the request body. Confirm the desired behavior with the examples in the issue: brackets should not be added automatically, while an explicitly named key such as "data[]" should remain usable.
Written by the indexing model from the issue text.
Description
Say I want to post an array of data to a remote source:
array = [1,2,3]
Unirest.post "https://www.my-website.com", parameters: { data: array }
When I receive the HTTP request on my-website.com, the body of the POST looks like this: data[]=1&data[]=2&data[]=3
According to this StackOverflow post, those square brackets are a convention to "address a limitation of PHP, which doesn't generate an array automatically if multiple values with the same name are submitted". All well and good if I'm posting to a PHP server, but if I'm posting to a different kind of server (in my case NancyFx), I can't easily get that data into an array.
I think it would make sense to get rid of these brackets by default and allow developers using unirest-ruby to post to a PHP server to do something like this:
array = [1,2,3]
Unirest.post "https://www.my-website.com", parameters: { "data[]": array }
- Dominant language
- Ruby
- Stars
- 364
- Forks
- 76
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Kong/unirest-ruby
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
Kong/unirest-ruby#55 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
Kong/unirest-ruby#54 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
Kong/unirest-ruby#53 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
Kong/unirest-ruby#52 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
Kong/unirest-ruby#51 ·
All issues in Kong/unirest-ruby
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
we-promise/sure#5844 ·
Maintainers usually reply within 1 day
-
chore
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
lugassawan/swe-workbench#841 ·
-
Difficulty 2/5 Under an hour Newbie friendliness 72/100
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
simp/pupmod-simp-simp#428 ·