{"_id":"parse-nested-form-data","_rev":"2-b47aee51ece00c47fefd9c0b824aab00","name":"parse-nested-form-data","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"parse-nested-form-data","version":"1.0.0","keywords":["FormData","parse","nested","form","array","object","parse"],"author":{"name":"Christian Schurr","email":"chris@schurr.dev"},"license":"MIT","_id":"parse-nested-form-data@1.0.0","maintainers":[{"name":"milamer","email":"fischerc.it@gmail.com"}],"homepage":"https://github.com/milamer/parse-nested-form-data#readme","bugs":{"url":"https://github.com/milamer/parse-nested-form-data/issues"},"dist":{"shasum":"497fdba08d9d99c6425f49c589fd1e1d1c637034","tarball":"https://registry.npmjs.org/parse-nested-form-data/-/parse-nested-form-data-1.0.0.tgz","fileCount":12,"integrity":"sha512-lIeGMds1l6h6YXxhmcD4aD72xwFAqfDjuzh9dUMyS4h5WhimOfhmfeDiT3KZhqpj+XgaEyen+X9Ks9Y3+Rp5+g==","signatures":[{"sig":"MEYCIQDCohDSyduL2c3f2kvqvilrNL63f94slpTU9MJqc9NatAIhAKif2a6kEx6WVDee83RjBbsXaq6ce2KVQ2SFGycMnkdW","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":98730,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjuuHCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr7Gw//RAAeOzoV/ElJm3H6Z6Ai2mmt0icVzNRqbHis6uMYEnlINuWd\r\n/n+aTg8n4wUlTp5DhXl71tDNa2oSLAIvLTlYf3Mf4GV+A+a4aTO5lrc7i0VJ\r\n7y/SpdeYFTIizx2it/DlguZDmYRQx+ZyDPKWEkjloAQ6WNr61Tnh3IWCr2wi\r\nQQQWBDwXN438nzuzdU7YveAJlsckhj80ZIQLhQKplhx7FgnjSKv27sO4gMwr\r\ng8YhJKJ5Zp8Vb5sdeJ8LmUV51i7zR9vuRO3SrAVsCtZ7/Py+1KwZOcp2KjvK\r\nA0BtBZxHwBqY9Q+6CF+nJmhhRjje0vhzRTTyZ28X0O9P7hwrXGmw/R5yJLFg\r\nloEpIu8V9yEOiFBeymCdR9hufCkKiSDsR2gx9baOndvdyW/VBH1A8bwf2nNL\r\nz8B4vB6BDO8LZPNCBSeh5F7hYzjZlgE6tTdoz21fgSAn/+GWKrICMc82eZtA\r\ngw1y08XcaAQRRh1NtJ5L4gpOXNTGZtRUL91Mh6G2BdsEZe4WpO3vo18Uml7g\r\n8/mPuw/wj6xJUcDgu6sCd1zyn2Gv3SaKfiIxD1uxCj/UsTcy6FHuS1OFI7h8\r\nVTXeeX4NosM7XrkD8THVU8myzBPoRXW+8VKcZh8j+1IPdxvoD4IiM0m8psZd\r\n6a8VJt+FYL+NLEwBxmWwidL9zGF/cy0AK5c=\r\n=SEOo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/parse-nested-form-data.cjs.js","types":"dist/index.d.ts","module":"dist/parse-nested-form-data.esm.js","gitHead":"57200d3d525f0eb14ce9c95ea3bc2fdb33be31a1","scripts":{"lint":"kcd-scripts lint","test":"kcd-scripts test","build":"kcd-scripts build --bundle --environment BUILD_NAME:parseNestedFormData","clean":"rimraf dist coverage node_modules","setup":"npm install && npm run validate -s","validate":"kcd-scripts validate","build:toc":"npx doctoc .","typecheck":"kcd-scripts typecheck","test:update":"npm test -- --updateSnapshot --coverage"},"_npmUser":{"name":"milamer","email":"fischerc.it@gmail.com"},"repository":{"url":"git+https://github.com/milamer/parse-nested-form-data.git","type":"git"},"_npmVersion":"6.14.17","description":"A tiny node module for parsing FormData by name into objects and arrays","directories":{},"_nodeVersion":"14.21.1","dependencies":{"@babel/runtime":"^7.19.0"},"eslintConfig":{"rules":{"one-var":["error","never"],"import/extensions":"off","max-lines-per-function":"off","@typescript-eslint/no-loop-func":"off","@typescript-eslint/no-unsafe-assignment":"off"},"extends":"./node_modules/kcd-scripts/eslint.js"},"eslintIgnore":["node_modules","coverage","dist"],"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^3.0.2","typescript":"^4.8.4","kcd-scripts":"^12.3.0","@remix-run/web-file":"^3.0.2","@remix-run/web-form-data":"^3.0.3"},"peerDependencies":{"@remix-run/web-file":">=3.0.0"},"peerDependenciesMeta":{"@remix-run/web-form-data":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/parse-nested-form-data_1.0.0_1673191874552_0.5408375548256537","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"parse-nested-form-data","version":"1.0.1","description":"A tiny node module for parsing FormData by name into objects and arrays","main":"dist/parse-nested-form-data.cjs.js","module":"dist/parse-nested-form-data.esm.js","types":"dist/index.d.ts","keywords":["FormData","parse","nested","form","array","object","parse"],"author":{"name":"Christian Schurr","email":"chris@schurr.dev"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/milamer/parse-nested-form-data.git"},"bugs":{"url":"https://github.com/milamer/parse-nested-form-data/issues"},"homepage":"https://github.com/milamer/parse-nested-form-data#readme","scripts":{"clean":"rimraf dist coverage node_modules","build:toc":"npx doctoc .","build":"kcd-scripts build --bundle --environment BUILD_NAME:parseNestedFormData","lint":"kcd-scripts lint","setup":"npm install && npm run validate -s","test":"kcd-scripts test","typecheck":"kcd-scripts typecheck","test:update":"npm test -- --updateSnapshot --coverage","validate":"kcd-scripts validate"},"dependencies":{"@babel/runtime":"^7.19.0"},"devDependencies":{"@remix-run/web-file":"^3.0.2","@remix-run/web-form-data":"^3.0.3","@types/minimatch":"^3.0.5","kcd-scripts":"^12.3.0","rimraf":"^3.0.2","typescript":"^4.8.4"},"peerDependencies":{"@remix-run/web-file":">=3.0.0"},"peerDependenciesMeta":{"@remix-run/web-form-data":{"optional":true}},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"import/extensions":"off","max-lines-per-function":"off","one-var":["error","never"],"@typescript-eslint/no-unsafe-assignment":"off","@typescript-eslint/no-loop-func":"off"}},"eslintIgnore":["node_modules","coverage","dist"],"gitHead":"527ad58eb486e32438f7198fb88315c20449d792","_id":"parse-nested-form-data@1.0.1","_nodeVersion":"14.21.3","_npmVersion":"6.14.18","dist":{"integrity":"sha512-BuMXaUOncsciUsL3N69cMvEHCeLAG6sRoFa7NPbw30Jn+klD47hlx/+Rq1MWrxsdQWu8157d2TnReea/NWTuFA==","shasum":"e164713a1131ec7cd5d645b0bc4849dfa5d1e655","tarball":"https://registry.npmjs.org/parse-nested-form-data/-/parse-nested-form-data-1.0.1.tgz","fileCount":12,"unpackedSize":109366,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHYehIqQFXe2HDjIBt/cwaI7hsX4M+/7re7KHQTYAq8XAiB1WeXJQJYuNvVTpAKd6q9mC/Ta9VEcpTWYiJ19/58X2A=="}]},"_npmUser":{"name":"milamer","email":"fischerc.it@gmail.com"},"directories":{},"maintainers":[{"name":"milamer","email":"fischerc.it@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/parse-nested-form-data_1.0.1_1778273504045_0.7220158812948887"},"_hasShrinkwrap":false}},"time":{"created":"2023-01-08T15:31:14.551Z","modified":"2026-05-08T20:51:44.300Z","1.0.0":"2023-01-08T15:31:14.756Z","1.0.1":"2026-05-08T20:51:44.193Z"},"bugs":{"url":"https://github.com/milamer/parse-nested-form-data/issues"},"author":{"name":"Christian Schurr","email":"chris@schurr.dev"},"license":"MIT","homepage":"https://github.com/milamer/parse-nested-form-data#readme","keywords":["FormData","parse","nested","form","array","object","parse"],"repository":{"type":"git","url":"git+https://github.com/milamer/parse-nested-form-data.git"},"description":"A tiny node module for parsing FormData by name into objects and arrays","maintainers":[{"name":"milamer","email":"fischerc.it@gmail.com"}],"readme":"<div align=\"center\">\n<h1>parse-nested-form-data</h1>\n\n<p>A tiny node module for parsing FormData by name into objects and arrays</p>\n</div>\n\n---\n\n<!-- prettier-ignore-start -->\n[![Build Status][build-badge]][build]\n[![Code Coverage][coverage-badge]][coverage]\n[![version][version-badge]][package]\n[![downloads][downloads-badge]][npmtrends]\n[![MIT License][license-badge]][license]\n[![All Contributors][all-contributors-badge]](#contributors-)\n[![PRs Welcome][prs-badge]][prs]\n[![Code of Conduct][coc-badge]][coc]\n<!-- prettier-ignore-end -->\n\n## The problem\n\n1.  You use Forms to upload data to your server (e.g. with remix-run)\n2.  You want a way to upload objects and arrays with booleans and numbers\n3.  You do not want to transfer the data per hand\n\n## This solution\n\nA parse functions that uses the name prop to tells the parser how to create an\nobject out of the values. You can tell the parser to do not parse empty values.\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n- [Installation](#installation)\n- [Name](#name)\n  - [Boolean](#boolean)\n  - [Number](#number)\n  - [Null](#null)\n  - [Array](#array)\n  - [Object](#object)\n- [Basic Usage](#basic-usage)\n  - [Transform values](#transform-values)\n- [Advanced usage](#advanced-usage)\n  - [Options](#options)\n  - [removeEmptyString: `[boolean]`](#removeemptystring-boolean)\n  - [transformEntry: `(entry: [path: string, value: string | File], defaultTransform: DefaultTransform) => [string, string | JsonLeafValue]`](#transformentry-entry-path-string-value-string--file-defaulttransform-defaulttransform--string-string--jsonleafvalue)\n- [Issues](#issues)\n  - [🐛 Bugs](#-bugs)\n  - [💡 Feature Requests](#-feature-requests)\n- [Contributors ✨](#contributors-)\n- [LICENSE](#license)\n- [Special Thanks](#special-thanks)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Installation\n\nThis module is distributed via [npm][npm] which is bundled with [node][node] and\nshould be installed as one of your project's `dependencies`:\n\n```sh\nnpm install parse-nested-form-data\n```\n\nand then import it in your project:\n\n```ts\nimport {parseFormData} from 'parse-nested-form-data'\n```\n\n## Name\n\nThe name prop is used to tell the parser how to create an object out of the\nvalues. The name prop is a string that can contain the following characters:\n\n- `.`: to create a nested object\n- `[]`: to create an array (pushes value)\n- `[$order]`: to create an array (sets value at index and squashes array)\n- `&`: to transform the value to a boolean\n- `-`: to transform the value to null\n- `+`: to transform the value to a number\n\n### Boolean\n\nIf the name prop starts with a `&` the value will be transformed to a boolean.\n\nTrue if the value has the following values:\n\n- `true`\n- `1`\n- `on`\n\n```ts\nconst formData = new FormData()\nformData.append('&isTrue', 'true')\nformData.append('&isFalse', 'false')\nformData.append('&isTrue1', '1')\nformData.append('&isFalse1', '0')\nformData.append('&isTrue2', 'on')\nformData.append('&isFalse2', 'off')\nparseFormData(formData)\n// {\n//   isTrue: true,\n//   isFalse: false,\n//   isTrue1: true,\n//   isFalse1: false,\n//   isTrue2: true,\n//   isFalse2: false,\n// }\n```\n\n### Number\n\nIf the name prop starts with a `+` the value will be transformed to a number.\n\n```ts\nconst formData = new FormData()\nformData.append('+number', '1')\nformData.append('+number2', '1.1')\nformData.append('+number3', 'a')\nparseFormData(formData)\n// {\n//   number: 1,\n//   number2: 1.1,\n//   number3: NaN,\n// }\n```\n\n### Null\n\nIf the name prop starts with a `-` the value will be transformed to null.\n\n```ts\nconst formData = new FormData()\nformData.append('-null', 'null')\nformData.append('-ignored', 'ignored')\nparseFormData(formData)\n// {\n//   null: null,\n//   ignored: null,\n// }\n```\n\n### Array\n\nIf a path of the name prop ends with `[]` the value will be pushed to an array.\nIf the path of the name prop ends with `[$order]` the value will be set at the\nindex of the order. Cannot be mixed with `[]`.\n\n```ts\nconst formData = new FormData()\nformData.append('array[0]', '1')\nformData.append('array[1]', '2')\nformData.append('array[2]', '3')\nformData.append('array[3]', '4')\nparseFormData(formData)\n// {\n//   array: ['1', '2', '3', '4'],\n// }\n```\n\n```ts\nconst formData = new FormData()\nformData.append('array[]', '1')\nformData.append('array[]', '2')\nformData.append('array[]', '3')\nparseFormData(formData)\n// {\n//   array: ['1', '2', '3'],\n// }\n```\n\nAlso works with nested objects:\n\n```ts\nconst formData = new FormData()\nformData.append('array[0].a', '1')\nformData.append('array[1].a', '2')\nformData.append('array[2].a', '3')\nparseFormData(formData)\n// {\n//   array: [{a: '1'}, {a: '2'}, {a: '3'}],\n// }\n```\n\nAlso works with nested arrays:\n\n```ts\nconst formData = new FormData()\nformData.append('array[0][]', '1')\nformData.append('array[0][]', '2')\nformData.append('array[1][]', '3')\nformData.append('array[1][]', '4')\nparseFormData(formData)\n// {\n//   array: [['1', '2'], ['3', '4']],\n// }\n```\n\n### Object\n\nIf the name prop contains a `.` the value will be nested in an object.\n\n```ts\nconst formData = new FormData()\nformData.append('object.a', '1')\nformData.append('object.b', '2')\nparseFormData(formData)\n// {\n//   object: {\n//     a: '1',\n//     b: '2',\n//   },\n// }\n```\n\n## Basic Usage\n\n### Transform values\n\n```ts\nconst formData = new FormData()\nformData.append('+a', '1')\nformData.append('&b', 'true')\nformData.append('-c', 'null')\nformData.append('d', 'foo')\nparseFormData(formData, defaultTransform)\n// => {a: 1, b: true, c: null, d: 'foo'}\n```\n\n## Advanced usage\n\nComplex examples:\n\n```ts\nconst formData = new FormData()\nformData.append('a[].b.c', '1')\nformData.append('a[].b.d', '2')\nformData.append('a[]', '3')\nformData.append('b[0]', '4')\nformData.append('+b[100]', '5')\nparseFormData(formData)\n// {\n//   a: [\n//     {\n//       b: {\n//         c: '1',\n//         d: '2',\n//       },\n//     },\n//     '3',\n//   ],\n//   b: ['4', 5],\n// }\n```\n\n### Options\n\nThe second argument is an option object with following properties:\n\n### removeEmptyString: `[boolean]`\n\n_Default: `false`_\n\nIf `true` empty strings will be removed from the result.\n\n```ts\nconst formData = new FormData()\nformData.append('foo[1].foo', '')\nformData.append('foo[1].bar', 'test2')\nformData.append('foo[0].foo', 'test3')\nformData.append('foo[0].baz', '4')\n\nparseFormData(formData, {removeEmptyString: true})\n// {foo: [{foo: 'test3', baz: '4'}, {bar: 'test2'}]}\n```\n\n### transformEntry: `(entry: [path: string, value: string | File], defaultTransform: DefaultTransform) => [string, string | JsonLeafValue]`\n\n```ts\nconst formData = new FormData()\nformData.append('a', 'a')\nformData.append('b', 'b')\nparseFormData(formData, {\n  transformEntry: ([path, value], defaultTransform) => {\n    return {\n      path,\n      value:\n        typeof value === 'string'\n          ? value.toUpperCase()\n          : defaultTransform(value),\n    }\n  },\n})\n// => {a: 'A', b: 'B'}\n```\n\n## Issues\n\n_Looking to contribute? Look for the [Good First Issue][good-first-issue]\nlabel._\n\n### 🐛 Bugs\n\nPlease file an issue for bugs, missing documentation, or unexpected behavior.\n\n[**See Bugs**][bugs]\n\n### 💡 Feature Requests\n\nPlease file an issue to suggest new features. Vote on feature requests by adding\na 👍. This helps maintainers prioritize what to work on.\n\n[**See Feature Requests**][requests]\n\n## Contributors ✨\n\nThanks goes to these people ([emoji key][emojis]):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n  </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors][all-contributors] specification.\nContributions of any kind welcome!\n\n## LICENSE\n\nMIT\n\n## Special Thanks\n\nSpecial thanks to Kent C. Dodds and his [match-sorter][match-sorter] package\nwhere most of the setup is from.\n\n<!-- prettier-ignore-start -->\n[npm]: https://www.npmjs.com\n[node]: https://nodejs.org\n[build-badge]: https://img.shields.io/github/actions/workflow/status/milamer/parse-nested-form-data/validate.yml?branch=main&logo=github&style=flat-square\n[build]: https://github.com/milamer/parse-nested-form-data/actions?query=workflow%3Avalidate\n[coverage-badge]: https://img.shields.io/codecov/c/github/milamer/parse-nested-form-data.svg?style=flat-square\n[coverage]: https://codecov.io/github/milamer/parse-nested-form-data\n[version-badge]: https://img.shields.io/npm/v/parse-nested-form-data.svg?style=flat-square\n[package]: https://www.npmjs.com/package/parse-nested-form-data\n[downloads-badge]: https://img.shields.io/npm/dm/parse-nested-form-data.svg?style=flat-square\n[npmtrends]: https://www.npmtrends.com/parse-nested-form-data\n[license-badge]: https://img.shields.io/npm/l/parse-nested-form-data.svg?style=flat-square\n[license]: https://github.com/milamer/parse-nested-form-data/blob/master/LICENSE\n[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\n[prs]: http://makeapullrequest.com\n[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square\n[coc]: https://github.com/milamer/parse-nested-form-data/blob/master/CODE_OF_CONDUCT.md\n[emojis]: https://github.com/all-contributors/all-contributors#emoji-key\n[all-contributors]: https://github.com/all-contributors/all-contributors\n[all-contributors-badge]: https://img.shields.io/github/all-contributors/milamer/parse-nested-form-data?color=orange&style=flat-square\n[bugs]: https://github.com/milamer/parse-nested-form-data/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug\n[requests]: https://github.com/milamer/parse-nested-form-data/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement\n[good-first-issue]: https://github.com/milamer/parse-nested-form-data/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement+label%3A%22good+first+issue%22\n[match-sorter]: https://github.com/kentcdodds/match-sorter/blob/main/README.md\n<!-- prettier-ignore-end -->\n","readmeFilename":"README.md"}