Skip to content

Fix HTTPie JSON array fields (key[]=value) - #101

Open
vulragrag-star wants to merge 1 commit into
rs:masterfrom
vulragrag-star:fix/httpie-json-array-fields
Open

vulragrag-star wants to merge 1 commit into
rs:masterfrom
vulragrag-star:fix/httpie-json-array-fields

Conversation

@vulragrag-star

Copy link
Copy Markdown

HTTPie / xh treat tables[]=users as an array field:

{"tables": ["users"]}

curlie was sending the brackets as part of the key name:

{"tables[]": "users"}

Parse name[] request items as JSON array appends (including repeated
key[]=… and key[]:=… raw JSON values).

Fixes #80

Test plan

  • go test ./...
  • curlie httpbin.org/post tables[]=users → {"tables":["users"]}
  • curlie httpbin.org/post tables[]=users tables[]=admins → {"tables":["users","admins"]}
  • curlie httpbin.org/post 'ids[]:=1' 'ids[]:=2' → {"ids":[1,2]}

Treat request items ending in [] as array appends so
tables[]=users becomes {"tables":["users"]}, matching
httpie/xh. Fixes rs#80.
@God-damnit-all

Copy link
Copy Markdown

@rs Would you approve the workflow so it compiles a test build?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTPie JSON array syntax doesn’t work

2 participants