Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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.