{"_id":"@adaskothebeast/http-params-processor-key-bracket-notation","_rev":"4-d1adc5484f13c5091e29ebb6afb6ac17","name":"@adaskothebeast/http-params-processor-key-bracket-notation","dist-tags":{"latest":"12.0.0"},"versions":{"10.0.0":{"name":"@adaskothebeast/http-params-processor-key-bracket-notation","version":"10.0.0","_id":"@adaskothebeast/http-params-processor-key-bracket-notation@10.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"dist":{"shasum":"eaa87ca05e09afeb7b3bbd84f05f66059c3f793a","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-key-bracket-notation/-/http-params-processor-key-bracket-notation-10.0.0.tgz","fileCount":15,"integrity":"sha512-jkzTMFwVtfmOdGs9naB3GQdOv7ngAI8CyodVe5eqPzaPiHQTKGtHwU/c020YAZ1heUCGZpuK89vg3+NjwmZtPQ==","signatures":[{"sig":"MEUCIBK1RZrOvp966dvpe1C3iNKstsWLHkLPw81TkY6fPSLFAiEA7aJOgjQWqpfGY7K3Oy39IR9yCv3yw0oQ4N4JdwCD1W4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28005},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"1e61d6323f67038b9af916e4f3d263a73fe76497","_npmUser":{"name":"adasko","email":"adaskothebeast@gmail.com"},"_npmVersion":"11.6.2","description":"> Transform complex TypeScript objects into query parameters for Angular, Axios, Fetch, and more","directories":{},"sideEffects":false,"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"peerDependencies":{"@adaskothebeast/http-params-processor-core":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-key-bracket-notation_10.0.0_1768077111371_0.0612277486378483","host":"s3://npm-registry-packages-npm-production"}},"11.0.0":{"name":"@adaskothebeast/http-params-processor-key-bracket-notation","version":"11.0.0","author":{"url":"https://github.com/adaskothebeast","name":"Adam Pluciński","email":"adaskothebeast@gmail.com"},"license":"MIT","_id":"@adaskothebeast/http-params-processor-key-bracket-notation@11.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"dist":{"shasum":"4c6adbb4ec0f8520bb2990dff5c657dc795ee813","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-key-bracket-notation/-/http-params-processor-key-bracket-notation-11.0.0.tgz","fileCount":8,"integrity":"sha512-E/NIb1TsCQJrSynJNmReorbRWFeNam1jgKSXpbVfI4T0gTUHS67BCH3b5KvCSvsahHc3/cgjtc/LE26SMJKKhA==","signatures":[{"sig":"MEUCIC206YWaNt7MwtZ/JoCLTbTbZ7CfPLdI/l5TDPSEyxpDAiEA/fKAK7qTl2sNYiSXc2vRwlZvgryhLF7yjDryol8/cg0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-key-bracket-notation@11.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":39115},"main":"./index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e4a107d2-e4f4-4e63-a58f-8917cda88e8e"}},"repository":{"url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git","type":"git"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-key-bracket-notation_11.0.0_1768758180645_0.14084052397263447","host":"s3://npm-registry-packages-npm-production"}},"11.1.0":{"name":"@adaskothebeast/http-params-processor-key-bracket-notation","version":"11.1.0","author":{"url":"https://github.com/adaskothebeast","name":"Adam Pluciński","email":"adaskothebeast@gmail.com"},"license":"MIT","_id":"@adaskothebeast/http-params-processor-key-bracket-notation@11.1.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"dist":{"shasum":"d49d57bf5284c25823d3ad22715a11b2fbb0b84c","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-key-bracket-notation/-/http-params-processor-key-bracket-notation-11.1.0.tgz","fileCount":8,"integrity":"sha512-5hDIlFDq6mPdTSwnL7Br+GVmn2mreShmS6p8VoNLtJ6wvKQ4b2Kmcn9Odq2b+fajQrSknOuF9M+aUZY5VBMJ/w==","signatures":[{"sig":"MEYCIQDjXW2vTSTUf/s/Em4+fB2LAEPlIzNCGYRPL1SzGrAm9AIhAKYYeJRZ78DSzO71f/NACituKXuBhNKSJBalJmrg3qES","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-key-bracket-notation@11.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":39115},"main":"./index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e4a107d2-e4f4-4e63-a58f-8917cda88e8e"}},"repository":{"url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git","type":"git"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-key-bracket-notation_11.1.0_1768758918865_0.9971215758675356","host":"s3://npm-registry-packages-npm-production"}},"12.0.0":{"name":"@adaskothebeast/http-params-processor-key-bracket-notation","version":"12.0.0","description":"Bracket notation key formatting strategy for HttpParamsProcessor, matching PHP, Laravel and Symfony query parameter binding.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","key-formatting","bracket-notation","php","laravel","symfony"],"license":"MIT","author":{"name":"Adam Pluciński","email":"adaskothebeast@gmail.com","url":"https://github.com/adaskothebeast"},"repository":{"type":"git","url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git"},"bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","type":"module","sideEffects":false,"main":"./index.cjs","module":"./index.js","types":"./index.d.ts","peerDependencies":{"@adaskothebeast/http-params-processor-core":"^12.0.0"},"exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"gitHead":"73d31a6c26a6f2819f6c98aabb36659532e4cdd0","_id":"@adaskothebeast/http-params-processor-key-bracket-notation@12.0.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-99qVhjL7wTUc5J7r0Gu1ltUIaattGEG7mCbyICZ5/JE/3c9RqbfK9lzvdvTPWx86gCSlyFCzut3Ro11SJxnsRw==","shasum":"241e1a5e19ddb578183b8424dd46775f7e78de27","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-key-bracket-notation/-/http-params-processor-key-bracket-notation-12.0.0.tgz","fileCount":9,"unpackedSize":12576,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC/UChpt6dr+nXGoDlLFzDOBrr9cNTtJCYxvPiUUymOwgIgDj+dz4HYbmiNFwWnW9NVyZAghtbdfLcQZJK2uaFMmmc="}]},"_npmUser":{"name":"adasko","email":"adaskothebeast@gmail.com"},"directories":{},"maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/http-params-processor-key-bracket-notation_12.0.0_1785235918499_0.0539763824999"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-10T20:31:51.195Z","modified":"2026-07-28T10:51:58.929Z","10.0.0":"2026-01-10T20:31:51.538Z","11.0.0":"2026-01-18T17:43:00.777Z","11.1.0":"2026-01-18T17:55:18.997Z","12.0.0":"2026-07-28T10:51:58.688Z"},"bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"author":{"name":"Adam Pluciński","email":"adaskothebeast@gmail.com","url":"https://github.com/adaskothebeast"},"license":"MIT","homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","repository":{"type":"git","url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git"},"maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"readme":"# 🔲 @adaskothebeast/http-params-processor-key-bracket-notation\n\n**PHP style bracket notation key formatting for [HttpParamsProcessor](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor): every level of nesting becomes `user[profile][email]`, `items[0]`.**\n\n[![npm](https://img.shields.io/npm/v/%40adaskothebeast%2Fhttp-params-processor-key-bracket-notation?color=cb3837&logo=npm)](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-bracket-notation)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nNo runtime dependency beyond `core` (its only peer dependency, `^12.0.0`). ESM + CJS. `sideEffects: false`.\n\n---\n\n## 📦 Install\n\n```bash\nnpm i @adaskothebeast/http-params-processor-key-bracket-notation @adaskothebeast/http-params-processor-core\n```\n\n---\n\n## 🎯 What it does\n\nThis is a **key formatting strategy**: it decides how nested keys are spelled while `ParamsProcessor` walks your object graph. It replaces the core default (dot notation for object properties) with brackets at every level, which is the shape PHP's `parse_str`, Laravel, Symfony, Rack and the Node `qs` library parse back into nested structures.\n\n| Input                        | `DefaultKeyFormattingStrategy` (core) | `BracketNotationKeyFormattingStrategy` |\n| ---------------------------- | ------------------------------------- | -------------------------------------- |\n| `{ user: { name: 'John' } }` | `p.user.name`                         | `p[user][name]`                        |\n| `{ items: ['a', 'b'] }`      | `p.items[0]`, `p.items[1]`            | `p[items][0]`, `p[items][1]`           |\n| `{ arr: [{ id: '1' }] }`     | `p.arr[0].id`                         | `p[arr][0][id]`                        |\n\nArray keys are identical to the core default (`items[0]`); only object property keys change.\n\n---\n\n## 🧰 API\n\n### `BracketNotationKeyFormattingStrategy`\n\nImplements `IKeyFormattingStrategy` from `core`.\n\n| Member                                       | Returns  | Result                               |\n| -------------------------------------------- | -------- | ------------------------------------ |\n| `new BracketNotationKeyFormattingStrategy()` | -        | No constructor options               |\n| `formatObjectKey(parentKey, propertyKey)`    | `string` | `` `${parentKey}[${propertyKey}]` `` |\n| `formatArrayKey(parentKey, index)`           | `string` | `` `${parentKey}[${index}]` ``       |\n\n`transformComplexObject` is not implemented, so traversal is never short-circuited: nested objects and arrays are always walked down to primitives.\n\n---\n\n## ⚡ Usage\n\n```ts\nimport { ParamsProcessor } from '@adaskothebeast/http-params-processor-core';\nimport { BracketNotationKeyFormattingStrategy } from '@adaskothebeast/http-params-processor-key-bracket-notation';\n\nconst processor = new ParamsProcessor({\n  keyFormatter: new BracketNotationKeyFormattingStrategy(),\n});\n\nprocessor.process('p', {\n  user: { name: 'John', profile: { email: 'john@example.com' } },\n  items: ['a', 'b'],\n});\n// [\n//   ['p[user][name]', 'John'],\n//   ['p[user][profile][email]', 'john@example.com'],\n//   ['p[items][0]', 'a'],\n//   ['p[items][1]', 'b'],\n// ]\n```\n\nThe very same `keyFormatter` option is accepted by every adapter (`-angular`, `-angular-resource`, `-fetch`, `-axios`, `-react-tanstack-query`, `-react-swr`), because they all forward their options object to `ParamsProcessor`.\n\n---\n\n## 🎛️ Options and configuration\n\nThere are no constructor options - bracket notation has exactly one shape. What you can choose is **scope**:\n\n```ts\nconst strategy = new BracketNotationKeyFormattingStrategy();\n\n// instance-wide default\nconst processor = new ParamsProcessor({ keyFormatter: strategy });\n\n// or per call, overriding the instance default\nprocessor.toQueryString('p', filter, { keyFormatter: strategy });\n```\n\nThe strategy is stateless, so a single instance can be shared across processors and calls.\n\nIf you need `items[]` instead of `items[0]` (idiomatic Rails/Rack), use [`-key-rails`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-rails); it formats objects exactly the same way and only differs in array keys.\n\n---\n\n## 📤 Output examples\n\n```ts\nconst processor = new ParamsProcessor({\n  keyFormatter: new BracketNotationKeyFormattingStrategy(),\n});\n\nprocessor.process('p', { arr: [{ id: '1', innerArr: [{ id: '1.1' }] }] });\n```\n\n```text\np[arr][0][id]                 = 1\np[arr][0][innerArr][0][id]    = 1.1\n```\n\n```ts\nprocessor.toQueryString('p', { user: { name: 'John' } });\n// p%5Buser%5D%5Bname%5D=John\n\nprocessor.toPlainObject('p', { items: ['a', 'b'] });\n// { 'p[items][0]': 'a', 'p[items][1]': 'b' }\n```\n\nServer side, `p[user][name]=John` binds to `$_GET['p']['user']['name']` in PHP, to `params[:p][:user][:name]` in Rack/Rails and to `{ p: { user: { name: 'John' } } }` with `qs.parse` (Express `extended` query parser).\n\n---\n\n## ⚠️ Edge cases\n\n- Brackets are **percent encoded** by `toQueryString` and `toURLSearchParams` (`p%5Buser%5D`). That is what every mainstream backend expects; `process` returns raw, unencoded keys.\n- Numeric object property keys stay object keys: `formatObjectKey('data', '0')` gives `data[0]`, which is indistinguishable from an array element - a backend may bind such an object as a list.\n- An **empty root key** produces keys that start with a bracket (`process('', { user: 1 })` gives `[user]`). Pass a real root name.\n- Property names containing `[`, `]` or `.` are inserted verbatim into the key, so they can break the backend's own bracket parser after encoding. Rename such properties before serializing.\n- Very deep graphs produce long keys; some servers and proxies cap query string length (often 2 - 8 KB).\n- `null` and `undefined` values, `$type` discriminators, empty objects and empty arrays are handled by `core`, not by this strategy: they simply never reach `formatObjectKey`/`formatArrayKey`.\n- Circular references still throw `Error: Circular reference detected at key: <key>` from `core`.\n\n---\n\n## 🔗 Related packages\n\n- Same object shape, different arrays: [`-key-rails`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-rails) (`items[]`)\n- Other key strategies: [`-key-flat`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-flat) (`user_name`), [`-key-custom-delimiter`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-custom-delimiter) (`user:name`), [`-key-json`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-json) (whole subtree as one JSON value)\n- Engine: [`-core`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-core) (ships `DefaultKeyFormattingStrategy`, the dot notation default)\n\nFull matrix and adapter recipes: [main README](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor#readme).\n\n---\n\n## 📄 License\n\n[MIT](./LICENSE) © Adam Pluciński\n","readmeFilename":"README.md","description":"Bracket notation key formatting strategy for HttpParamsProcessor, matching PHP, Laravel and Symfony query parameter binding.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","key-formatting","bracket-notation","php","laravel","symfony"]}