https://github.com/firstandthird/formobj
Takes a form and outputs to json
https://github.com/firstandthird/formobj
Last synced: 8 months ago
JSON representation
Takes a form and outputs to json
- Host: GitHub
- URL: https://github.com/firstandthird/formobj
- Owner: firstandthird
- License: mit
- Created: 2016-11-05T15:21:07.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T14:06:26.000Z (over 3 years ago)
- Last Synced: 2025-06-20T10:45:42.495Z (9 months ago)
- Language: JavaScript
- Size: 479 KB
- Stars: 1
- Watchers: 7
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# formobj  [](https://travis-ci.org/firstandthird/formobj)
Converts form elements with a `name` attribute to JSON.
## Installation
```sh
npm install formobj
```
## Usage
```html
Blue
White
Red
```
```js
import FormObj from 'formobj';
const form = new FormObj(document.getElementById('SuperAmazingForm'));
const data = form.getJSON();
```
## Outputs
```json
{
"username": "superdude",
"capecolors": ["blue", "red"],
"powerful": true,
"smart": false
}
```
**Note:** Items that share the same name will become an array of values.