Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/firstandthird/formobj
Takes a form and outputs to json
https://github.com/firstandthird/formobj
Last synced: 3 days 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 (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T14:06:26.000Z (about 2 years ago)
- Last Synced: 2025-01-13T06:44:24.511Z (9 days ago)
- Language: JavaScript
- Size: 479 KB
- Stars: 1
- Watchers: 8
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# formobj ![npm](https://img.shields.io/npm/v/formobj.svg) [![Build Status](https://travis-ci.org/firstandthird/formobj.svg?branch=master)](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.