{"_id":"@alvinsj/form-serialize","_rev":"3-24a7cafab5c59eaa5c31a08f5dd9c3ef","name":"@alvinsj/form-serialize","description":"serialize html forms","dist-tags":{"latest":"0.7.2-alpha.1"},"versions":{"0.7.1":{"name":"@alvinsj/form-serialize","version":"0.7.1","description":"serialize html forms","main":"index.js","directories":{"test":"test"},"devDependencies":{"domify":"~1.4.0","zuul":"~3.10.1"},"scripts":{"test":"zuul -- test/index.js","test-local":"zuul --local -- test/index.js"},"repository":{"type":"git","url":"git://github.com/shtylman/form-serialize.git"},"keywords":["form","serialize"],"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/shtylman/form-serialize/issues"},"gitHead":"228e1b738c3297bde5c003817fd371d7385e3c59","homepage":"https://github.com/shtylman/form-serialize#readme","_id":"@alvinsj/form-serialize@0.7.1","_shasum":"73280c4c4b6971ba17c0913854747d59e5ccb165","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.2.1","_npmUser":{"name":"alvinsj","email":"text@alvinsj.net"},"dist":{"shasum":"73280c4c4b6971ba17c0913854747d59e5ccb165","tarball":"https://registry.npmjs.org/@alvinsj/form-serialize/-/form-serialize-0.7.1.tgz","integrity":"sha512-mn2w+7HQHGrt+6fG1w4OnGGqML6/3Lw/DgDVNJB86yeub4f0Gcmv8rtLyHZoOhq+6dKi9BC7qZ1fKpRhgrAf5Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCczPrqqYggASVKGNcMhkr+XUGA7nAEkkLpWAr0XnuYcwIhAI2Ijfm+aK5cSf36HRfrI4sTRTIfYhag/r1/MwuiD0v3"}]},"maintainers":[{"name":"alvinsj","email":"text@alvinsj.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/form-serialize-0.7.1.tgz_1508223347479_0.9024833468720317"}},"0.7.2-alpha.1":{"name":"@alvinsj/form-serialize","version":"0.7.2-alpha.1","description":"serialize html forms","main":"index.js","directories":{"test":"test"},"devDependencies":{"domify":"~1.4.0","zuul":"~3.10.1"},"scripts":{"test":"zuul -- test/index.js","test-local":"zuul --local -- test/index.js"},"repository":{"type":"git","url":"git://github.com/shtylman/form-serialize.git"},"keywords":["form","serialize"],"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/shtylman/form-serialize/issues"},"gitHead":"26d149334e2f03ffd9c563542f4ddabe2a912782","homepage":"https://github.com/shtylman/form-serialize#readme","_id":"@alvinsj/form-serialize@0.7.2-alpha.1","_shasum":"66a774f38139d067dad498d4e5a48eadf6592afb","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.2.1","_npmUser":{"name":"alvinsj","email":"text@alvinsj.net"},"dist":{"shasum":"66a774f38139d067dad498d4e5a48eadf6592afb","tarball":"https://registry.npmjs.org/@alvinsj/form-serialize/-/form-serialize-0.7.2-alpha.1.tgz","integrity":"sha512-fUgQXtwjHRUzE2U8Ujyx8PY+FBptD/lKQnCB0PCQ0X5PA+nz+LK17sBYnv1JLpNvHQpmdo0NaGqeiuMXr77/NA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCsuPrBG71/V5KAa3q8QsdrAKQPQzHJxuCja1Ari6ZSFQIgJSIqOLd0a01pcq8nzftts2g6JccQ1D1ys7DIihsxY+U="}]},"maintainers":[{"name":"alvinsj","email":"text@alvinsj.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/form-serialize-0.7.2-alpha.1.tgz_1508224459251_0.3675983906723559"}}},"readme":"# form-serialize [![Build Status](https://travis-ci.org/defunctzombie/form-serialize.png?branch=master)](https://travis-ci.org/defunctzombie/form-serialize)\n\nserialize form fields to submit a form over ajax\n\n## install\n\n```shell\nnpm install form-serialize\n```\n\n## use\n\nform-serialize supports two output formats, url encoded (default) or hash (js objects).\n\nLets serialize the following html form:\n```html\n<form id=\"example-form\">\n\t<input type=\"text\" name=\"foo\" value=\"bar\"/>\n\t<input type=\"submit\" value=\"do it!\"/>\n</form>\n```\n\n```js\nvar serialize = require('form-serialize');\nvar form = document.querySelector('#example-form');\n\nvar str = serialize(form);\n// str -> \"foo=bar\"\n\nvar obj = serialize(form, { hash: true });\n// obj -> { foo: 'bar' }\n```\n\n## api\n\n### serialize(form [, options])\n\nReturns a serialized form of a HTMLForm element. Output is determined by the serializer used. Default serializer is url-encoded.\n\narg | type | desc\n:--- | :--- | :---\nform | HTMLForm | must be an HTMLForm element\noptions | Object | optional options object\n\n#### options\n\noption | type | default | desc\n:--- | :--- | :---: | :---\nhash | boolean | false | if `true`, the hash serializer will be used for `serializer` option\nserializer | function | url-encoding | override the default serializer (hash or url-encoding)\ndisabled | boolean | false | if `true`, disabled fields will also be serialized\nempty | boolean | false | if `true`, empty fields will also be serialized\n\n### custom serializer\n\nSerializers take 3 arguments: `result`, `key`, `value` and should return a newly updated result.\n\nSee the example serializers in the index.js source file.\n\n## notes\n\nonly [successful control](http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2) form fields are serialized (with the exception of disabled fields if disabled option is set)\n\nmultiselect fields with more than one value will result in an array of values in the `hash` output mode using the default hash serializer\n\n### explicit array fields\n\nFields who's name ends with `[]` are **always** serialized as an array field in `hash` output mode using the default hash serializer.\nThe field name also gets the brackets removed from its name.\n\nThis does not affect `url-encoding` mode output in any way.\n\n```html\n<form id=\"example-form\">\n\t<input type=\"checkbox\" name=\"foo[]\" value=\"bar\" checked />\n\t<input type=\"checkbox\" name=\"foo[]\" value=\"baz\" />\n\t<input type=\"submit\" value=\"do it!\"/>\n</form>\n```\n\n```js\nvar serialize = require('form-serialize');\nvar form = document.querySelector('#example-form');\n\nvar obj = serialize(form, { hash: true });\n// obj -> { foo: ['bar'] }\n\nvar str = serialize(form);\n// str -> \"foo[]=bar\"\n\n```\n\n### indexed arrays\n\nAdding numbers between brackets for the array notation above will result in a hash serialization with explicit ordering based on the index number regardless of element ordering.\n\nLike the \"[explicit array fields](explicit-array-fields)\" this does not affect url-encoding mode output in any way.\n\n```html\n<form id=\"todos-form\">\n\t<input type=\"text\" name=\"todos[1]\" value=\"milk\" />\n\t<input type=\"text\" name=\"todos[0]\" value=\"eggs\" />\n\t<input type=\"text\" name=\"todos[2]\" value=\"flour\" />\n</form>\n```\n\n```js\nvar serialize = require('form-serialize');\nvar form = document.querySelector('#todos-form');\n\nvar obj = serialize(form, { hash: true });\n// obj -> { todos: ['eggs', 'milk', 'flour'] }\n\nvar str = serialize(form);\n// str -> \"todos[1]=milk&todos[0]=eggs&todos[2]=flour\"\n\n```\n\n### nested objects\n\nSimilar to the indexed array notation, attribute names can be added by inserting a string value between brackets. The notation can be used to create deep objects and mixed with the array notation.\n\nLike the \"[explicit array fields](explicit-array-fields)\" this does not affect url-encoding mode output.\n\n```html\n<form id=\"nested-example\">\n\t<input type=\"text\" name=\"foo[bar][baz]\" value=\"qux\" />\n\t<input type=\"text\" name=\"foo[norf][]\" value=\"item 1\" />\n</form>\n```\n\n```js\nvar serialize = require('form-serialize');\nvar form = document.querySelector('#todos-form');\n\nvar obj = serialize(form, { hash: true });\n// obj -> { foo: { bar: { baz: 'qux' } }, norf: [ 'item 1' ] }\n\n```\n\n## references\n\nThis module is based on ideas from jQuery serialize and the Form.serialize method from the prototype library\n\n## license\n\nMIT\n","maintainers":[{"name":"alvinsj","email":"text@alvinsj.net"}],"time":{"modified":"2022-06-12T14:36:12.719Z","created":"2017-10-17T06:55:47.599Z","0.7.1":"2017-10-17T06:55:47.599Z","0.7.2-alpha.1":"2017-10-17T07:14:19.404Z"},"homepage":"https://github.com/shtylman/form-serialize#readme","keywords":["form","serialize"],"repository":{"type":"git","url":"git://github.com/shtylman/form-serialize.git"},"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"bugs":{"url":"https://github.com/shtylman/form-serialize/issues"},"license":"MIT","readmeFilename":"README.md"}