{"_id":"form-serializer","_rev":"8-30bfe65b2952beb26c4989b4b9a312a3","name":"form-serializer","description":"serialize form fields into an object or JSON","dist-tags":{"latest":"2.5.0"},"versions":{"2.0.1":{"name":"form-serializer","version":"2.0.1","description":"serialize form fields into an object or JSON","main":"lib/form-serializer.js","scripts":{"test":"mocha -R tap","browserify":"browserify lib/plugin.js > jquery.serialize-object.js"},"repository":{"type":"git","url":"https://github.com/macek/jquery-serialize-object.git"},"keywords":["form","serialize","json","object"],"author":{"name":"macek","email":"paulmacek@gmail.com"},"license":"BSD","bugs":{"url":"https://github.com/macek/jquery-serialize-object/issues"},"devDependencies":{"jquery-extend":"~2.0.3","mocha":"~1.12.1","browserify":"~2.29.1"},"_id":"form-serializer@2.0.1","dist":{"shasum":"00f626ee302988817aab329d7c8be221baf73d96","tarball":"https://registry.npmjs.org/form-serializer/-/form-serializer-2.0.1.tgz","integrity":"sha512-d7tGipGV+FOyn2PVOJX3j3V0tFP4WWgFFb6BtU0B8SK/eWzQA0jlyzMlGTh9vAKJfYMZCaJpCaiNO11MlsoS4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDpliYc61CVWO3pXPGEVFym0ikCcXLyfQdn4WqH1+jr3gIhAPOihNVwtMPmijo7ZLjZjTTZlwQuvUBGNsbXk6M6MXoq"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"macek","email":"paulmacek@gmail.com"},"maintainers":[{"name":"macek","email":"paulmacek@gmail.com"}]},"2.5.0":{"name":"form-serializer","version":"2.5.0","description":"serialize form fields into an object or JSON","main":"./jquery.serialize-object.js","scripts":{"test":"npm run build && open ./test/test.html","build":"npm run minify","minify":"uglifyjs jquery.serialize-object.js -m -c --comments > dist/jquery.serialize-object.min.js"},"repository":{"type":"git","url":"https://github.com/macek/jquery-serialize-object"},"keywords":["form","serialize","json","object","jquery-plugin"],"plugin":{"type":"jQuery","name":"jQuery serializeObject"},"author":{"name":"macek","email":"paulmacek@gmail.com"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/macek/jquery-serialize-object/issues"},"devDependencies":{"uglify-js":"^2.4.16"},"gitHead":"68ec73289dcffa533770f07616633696c552bf6a","homepage":"https://github.com/macek/jquery-serialize-object","_id":"form-serializer@2.5.0","_shasum":"caea2facbc1bcee7f655d9136707133f3facb5a3","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"macek","email":"paulmacek@gmail.com"},"dist":{"shasum":"caea2facbc1bcee7f655d9136707133f3facb5a3","tarball":"https://registry.npmjs.org/form-serializer/-/form-serializer-2.5.0.tgz","integrity":"sha512-/ywBrSMOWrbpVYJFuin0OuOnqTas7gER1Eimi43D1iqQvNF6z1vY8KcWkC/YGt8zPE9k8KmyDVwIth6e5C1nxg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC+5GS/+1PpP1hl2Hm7mVTCYYkPU46tFbHbA8G9CeNijAiBIH4gmGcKEY2h6k5RTCCDltHnOYqWVIm+6swjkA1M80g=="}]},"maintainers":[{"name":"macek","email":"paulmacek@gmail.com"}]}},"readme":"jQuery Serialize Object\n=======================\n\n**As seen on StackOverflow: [Convert forms to JSON LIKE A BOSS][SO].**\n\nAdds the method `serializeObject` to jQuery, to perform complex form\nserialization into JavaScript objects.\n\nThe current implementation relies in `jQuery.serializeArray()` to grab the form\nattributes and then create the object using the input `name` attributes.\n\nThis means it will serialize the inputs that are supported by\n`.serializeArray()`, that use the standard W3C rules for [successful controls][w3c_controls]\nto determine which inputs should be included; in particular:\n\n* The input cannot be disabled and must contain a name attribute.\n* No submit button value is serialized since the form is not submitted using a button.\n* Data from `<input type=\"file\">` inputs are not serialized.\n\n\nInstallation\n------------\n\n**option 1: Bower**\n\n```sh\n$ bower install jquery-serialize-object\n```\n\n**option 2: Manual**\n\nCopy the `dist/jquery-serialize-object.min.js` to your project.\n\nYou can include the plugin in the `HEAD` element or at the bottom of your `BODY`\ntag. Wherever you choose to add it, it **must** be included after your jQuery.\n\n```html\n<head>\n  <script src=\"jquery.min.js\"></script>\n  <script src=\"jquery.serialize-object.min.js\"></script>\n</head>\n```\n\n2.0\n---\n\nVersion 2.0 takes jquery-serialize-object into maturity. It is now backed by a\nfull test suite so you can be confident that it will work in your web app.\n\nMoving ahead, on top of core serialization, `.serializeObject` will support\ncorrect serializaton for `boolean` and `number` values, resulting valid types\nfor both cases.\n\nLook forward to these `>= 2.5.0`\n\n**Update:** `>= 2.4.0` now serializes `<input type=\"checkbox\">` as a `boolean`. See\nthe [test][boolean] for specific behavior.\n\n\nAPI\n---\n\nGiven a basic HTML form\n\n```html\n<form id=\"contact\">\n  <input name=\"user[email]\" value=\"jsmith@example.com\">\n  <input name=\"user[pets][]\" type=\"checkbox\" value=\"cat\" checked>\n  <input name=\"user[pets][]\" type=\"checkbox\" value=\"dog\" checked>\n  <input name=\"user[pets][]\" type=\"checkbox\" value=\"bird\">\n  <input type=\"submit\">\n</form>\n```\n\n**.serializeObject** &mdash; serializes the selected form into a JavaScript object\n\n```js\n$('form#contact').serializeObject();\n//=> {user: {email: \"jsmith@example.com\", pets: [\"cat\", \"dog\"]}}\n```\n\n**.serializeJSON** &mdash; serializes the selected form into [JSON][json]\n\n```js\n$('form#contact').serializeJSON();\n//=> '{\"user\":{\"email\":\"jsmith@example.com\",\"pets\":[\"cat\",\"dog\"]}}'\n```\n\n**FormSerializer.patterns** &mdash; modify the patterns used to match field\nnames\n\nMany of you have requested to allow `-` in field names or use `.` to nest keys.\nYou can now configure these to your heart's content.\n\n[Hyphen][dash-notation] example\n\n```js\n$.extend(FormSerializer.patterns, {\n  validate: /^[a-z][a-z0-9_-]*(?:\\[(?:\\d*|[a-z0-9_-]+)\\])*$/i,\n  key:      /[a-z0-9_-]+|(?=\\[\\])/gi,\n  named:    /^[a-z0-9_-]+$/i\n});\n```\n\n[Dot-notation][dot-notation] example\n\n```js\n$.extend(FormSerializer.patterns, {\n  validate: /^[a-z][a-z0-9_]*(?:\\.[a-z0-9_]+)*(?:\\[\\])?$/i\n});\n```\n\n*Validating and Key parsing*\n\n* `validate` &mdash; only valid input names will be serialized; invalid names\n  will be skipped\n\n* `key` &mdash; this pattern parses all \"keys\" from the input name; You will\n  want to use `/g` as a modifier with this regexp.\n\n*Key styles*\n\n* `push` &mdash; pushe a value to an array\n\n  ```html\n  <input name=\"foo[]\" value=\"a\">\n  <input name=\"foo[]\" value=\"b\">\n  ```\n\n  ```js\n  $(\"form\").serializeObject();\n  //=> {foo: [a, b]}\n  ```\n\n* `fixed` &mdash; add a value to an array at a specified index\n\n  ```html\n  <input name=\"foo[2]\" value=\"a\">\n  <input name=\"foo[4]\" value=\"b\">\n  ```\n\n  ```js\n  $(\"form\").serializeObject();\n  //=> {foo: [, , \"a\", , \"b\"]}\n  ```\n\n* `named` &mdash; adds a value to the specified key\n\n  ```html\n  <input name=\"foo[bar]\" value=\"a\">\n  <input name=\"foo[bof]\" value=\"b\">\n  <input name=\"hello\" value=\"world\">\n  ```\n\n  ```js\n  $(\"form\").serializeObject();\n  //=> {foo: {bar: \"a\", bof: \"b\"}, hello: \"world\"}\n  ```\n\nTests\n-----\n\nIf you have [node.js][node] installed, as a convenience, you can run\n\n```sh\n$ npm test\n```\n\nIf you do not have node installed, simply\n\n```sh\n$ open ./test/test.html\n```\n\n\nCoffeeScript\n------------\n\nCoffeeScript has been dropped for `>= 2.0.0`. If members of the community would\nlike to support this, please feel free to add a CoffeeScript version.\n\nIf you'd like to use the the `1.0.0` version, it is still available [here][legacy].\n\n\nContributing\n------------\n\nAll pull requests **must** be backed by tests or they will be rejected.\n\nOnce you have finished your changes, build the new plugin:\n\n```sh\n$ npm run-script build\n```\n\n**Do not** bump the version. I will handle versioning.\n\n\n[SO]: http://stackoverflow.com/a/8407771/184600\n[w3c_controls]: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2\n[json]: http://json.org\n[node]: http://nodejs.org\n[legacy]: https://github.com/macek/jquery-serialize-object/releases/tag/1.0.0\n[dash-notation]: https://github.com/macek/jquery-serialize-object/issues/6\n[dot-notation]: https://github.com/macek/jquery-serialize-object/issues/4\n[boolean]: https://github.com/macek/jquery-serialize-object/blob/master/test/integration/encode-test.js","maintainers":[{"name":"macek","email":"paulmacek@gmail.com"}],"time":{"modified":"2022-06-18T03:01:56.597Z","created":"2013-11-25T07:53:32.531Z","2.0.1":"2013-11-25T07:53:33.452Z","2.5.0":"2015-07-10T19:33:08.209Z"},"author":{"name":"macek","email":"paulmacek@gmail.com"},"repository":{"type":"git","url":"https://github.com/macek/jquery-serialize-object"},"users":{"shieldax":true,"jackvial":true},"homepage":"https://github.com/macek/jquery-serialize-object","keywords":["form","serialize","json","object","jquery-plugin"],"bugs":{"url":"https://github.com/macek/jquery-serialize-object/issues"},"license":"BSD-3-Clause","readmeFilename":"README.md"}