{"id":17770068,"url":"https://github.com/j3rn/form_coder","last_synced_at":"2026-02-10T20:30:57.489Z","repository":{"id":62429665,"uuid":"455049757","full_name":"J3RN/form_coder","owner":"J3RN","description":"A Gleam library to encode and decode `x-www-form-urlencoded` data.","archived":false,"fork":false,"pushed_at":"2024-03-18T16:32:16.000Z","size":16,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T00:46:47.557Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Gleam","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/J3RN.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-03T06:08:23.000Z","updated_at":"2024-03-18T16:50:42.000Z","dependencies_parsed_at":"2024-10-26T21:52:34.814Z","dependency_job_id":"7ffc453f-e272-4cbf-9f34-e57114586c15","html_url":"https://github.com/J3RN/form_coder","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J3RN%2Fform_coder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J3RN%2Fform_coder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J3RN%2Fform_coder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J3RN%2Fform_coder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/J3RN","download_url":"https://codeload.github.com/J3RN/form_coder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246652736,"owners_count":20812177,"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","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-10-26T21:20:22.558Z","updated_at":"2026-02-10T20:30:57.451Z","avatar_url":"https://github.com/J3RN.png","language":"Gleam","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `form_coder`\n\nA Gleam library to encode and decode `x-www-form-urlencoded` data.\n\nThis data is a superset of your traditional GET query parameter format;\ne.g. `foo=bar\u0026baz=qux`. While there's no established standard for conveying data\nstructures such as lists and maps, `form_coder` follows the format used by both\nRails and Plug. Namely:\n\n- A list like `[#(\"foo\", [\"bar\", \"baz\"])]` is encoded to `foo[]=bar\u0026foo[]=baz`\n- A map like `[#(\"foo\", %{\"bar\" =\u003e \"qux\"})]` (map in Elixir syntax for brevity) is\n  encoded as `foo[bar]=qux`.\n\n## Examples\n\n### Encoding\n\n```gleam\n\u003e form_coder.encode([#(\"foo\", QStr(\"bar\")), #(\"baz\", QStr(\"qux\"))])\n\"foo=bar\u0026baz=qux\"\n```\n\n```gleam\n\u003e form_coder.encode([#(\"user_ids\", QList([QStr(\"1\"), QStr(\"2\")]))])\n\"user_ids[]=1\u0026user_ids[]=2\"\n```\n\n```gleam\n\u003e form_coder.encode([#(\"person\", QMap(dict.from_list([#(\"name\", QStr(\"Joe\")), #(\"age\", QStr(\"71\"))])))])\n\"person[age]=71\u0026person[name]=Joe\"\n```\n\n**What's with `QStr`, `QList`, and `QMap`?**\n\nWell, in the type specification, the argument must take the form\n`List(#(String, _))`, where I can choose what to replace `_` with. Choosing\nany one of `String`, `List`, or `Dict` would make using the other two very\ninconvenient. Using some type variable `a` would enforce that all \"values\"\nhave the same type (i.e. you can't have some values as strings and others as\nlists) and `form_coder` would have to know how to encode your arbitrary `a` and\nthat doesn't seem possible.\n\nSince Gleam doesn't have union types, I created an algebraic type with variants\nto wrap each supported type; hence `QStr`, `QList`, and `QMap`.\n\n### Decoding\n\n```gleam\n\u003e form_coder.decode(\"foo=bar\u0026baz=qux\", dynamic.list(of: dynamic.tuple2(dynamic.string, dynamic.string)))\n[#(\"foo\", \"bar\"), #(\"baz\", \"qux\")]\n```\n\nSupport for decoding the more sophisticated types (List, Map) is planned, but\nnot yet implemented.\n\n## Quick start\n\n```sh\ngleam build # Compile the project\ngleam test  # Run the tests\ngleam shell # Run an Erlang shell\n```\n\n## Installation\n\n```sh\ngleam add form_coder\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj3rn%2Fform_coder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj3rn%2Fform_coder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj3rn%2Fform_coder/lists"}