{"id":22750385,"url":"https://github.com/ruby2elixir/http_params_serializer","last_synced_at":"2025-09-04T18:51:11.564Z","repository":{"id":57505780,"uuid":"52435381","full_name":"ruby2elixir/http_params_serializer","owner":"ruby2elixir","description":"A small library to serialize deeply nested datastructures into HTTP parameters that most backends understand","archived":false,"fork":false,"pushed_at":"2016-02-24T14:00:41.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-08T13:43:02.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ruby2elixir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-24T10:51:47.000Z","updated_at":"2018-12-15T23:03:33.000Z","dependencies_parsed_at":"2022-09-26T17:51:47.249Z","dependency_job_id":null,"html_url":"https://github.com/ruby2elixir/http_params_serializer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ruby2elixir/http_params_serializer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby2elixir%2Fhttp_params_serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby2elixir%2Fhttp_params_serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby2elixir%2Fhttp_params_serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby2elixir%2Fhttp_params_serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby2elixir","download_url":"https://codeload.github.com/ruby2elixir/http_params_serializer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby2elixir%2Fhttp_params_serializer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271740595,"owners_count":24812637,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-11T04:14:33.678Z","updated_at":"2025-09-04T18:51:11.533Z","avatar_url":"https://github.com/ruby2elixir.png","language":"Elixir","readme":"# HttpParamsSerializer\n\n[![Build status](https://travis-ci.org/ruby2elixir/http_params_serializer.svg \"Build status\")](https://travis-ci.org/ruby2elixir/http_params_serializer)\n[![Hex version](https://img.shields.io/hexpm/v/http_params_serializer.svg \"Hex version\")](https://hex.pm/packages/http_params_serializer)\n![Hex downloads](https://img.shields.io/hexpm/dt/http_params_serializer.svg \"Hex downloads\")\n\n----\n\n\nA small library to serialize deeply nested datastructures into HTTP parameters that most backends do understand\n\n## tl;dr\n\nTurns this `Map`\n\n```elixir\n%{ a: %{ b: %{ d: [1,2], f: 4 } }, c: 3 }\n```\n\nor the equivalent `Keyword list`:\n\n```elixir\n[a: [b: [d: [1, 2], f: 4]], c: 3]\n```\n\ninto a `list of key-value tuples`:\n\n```elixir\n[\n  {\"a[b][d][]\", 1},\n  {\"a[b][d][]\", 2},\n  {\"a[b][f]\", 4},\n  {\"c\", 3}\n]\n```\n\nwhich can be easily turned into\n```\n\"a[b][d][]=1\u0026a[b][d][]=2\u0026a[b][f]=4\u0026c=3\"\n```\nfor communication with backend APIs.\n\n\n\n## Longer Explanation\n\nI couldn't find an Elixir package that serializes HTTP params as `maps` or nested `keyword lists` into a list of key-value pairs that many REST APIs (in Rails or similar MVC frameworks) require. So I've build one. Enjoy!\n\nThis is supposed to be the Elixir equivalent of [Jquery.param](http://api.jquery.com/jquery.param/) in JS world.\n\n\n## Features\n\n  - serialization of arbitrary deeply nested datastructures\n  - sorted keys for more predictable output\n  - the output (list with tuples) can be directly consumed by following Elixir/Erlang HTTP clients:\n    - [HTTPoison](https://github.com/edgurgel/httpoison)\n    - [Hackney](https://github.com/benoitc/hackney)\n\n## Usage\n\n```elixir\niex\u003e params = %{id: \"aaa-1234\",\n  account: %{name: \"Best\", last_name: \"User Eva\"},\n  balance: %{limit: 1000, currency: \"$\", balance: 1500},\n  roles: [\"admin\", \"manager\", \"staff\"]\n}\n%{account: %{last_name: \"User Eva\", name: \"Best\"},\n  balance: %{balance: 1500, currency: \"$\", limit: 1000}, id: \"aaa-1234\"}\niex\u003e params |\u003e HttpParamsSerializer.serialize\n[{\"account[last_name]\", \"User Eva\"}, {\"account[name]\", \"Best\"},\n {\"balance[balance]\", 1500}, {\"balance[currency]\", \"$\"},\n {\"balance[limit]\", 1000}, {\"id\", \"aaa-1234\"}, {\"roles[]\", \"staff\"},\n {\"roles[]\", \"manager\"}, {\"roles[]\", \"admin\"}]\n```\n\nWith HTTPoison:\n```elixir\nready = params |\u003e HttpParamsSerializer.serialize\nHTTPoison.Base.request!(:post, \"/some_endpoint\", [], {:form, ready})\n```\n\n\n\n## Gotchas\n\nWhen the input is a Map the order of keys for lists inside the map might be not the original order.\nThis is because Erlang Maps do not support ordering of keys.\n```\n## http://elixir-lang.org/getting-started/keywords-and-maps.html#maps\nMaps’ keys do not follow any ordering.\n```\n\n## Installation\n  1. Add http_params_serializer to your list of dependencies in `mix.exs`:\n\n        def deps do\n          [{:http_params_serializer, \"~\u003e 0.1\"}]\n        end\n\n\n## License\nCopyright © 2016 Roman Heinrich \u003croman.heinrich@gmail.com\u003e\n\nThis work is free. You can redistribute it and/or modify it under the\nterms of the MIT License. See the LICENSE file for more details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby2elixir%2Fhttp_params_serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby2elixir%2Fhttp_params_serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby2elixir%2Fhttp_params_serializer/lists"}