Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 1007 Bytes

Readme.md

File metadata and controls

51 lines (39 loc) · 1007 Bytes

serialize

Serialize forms into JSON object

Installation

$ component install JayceTDE/serialize

Dependencies

API

<form id="form">
    <input type="text" name="username" value="USERNAME" />
    <input type="password" name="password" value="PASSWORD" />
    <input type="text" name="birth.month" value="JANUARY" />
    <input type="text" name="birth.year" value="1980" />
    <input type="hidden" name="multiple" value="a" />
    <input type="hidden" name="multiple" value="b" />
    <input type="hidden" name="multiple" value="c" />
    <input type="submit" />
</form>
var serialize = require('serialize')
  , form = document.querySelector('#form')
;

serialize(form);
/*
{
  username: "USERNAME",
  password: "PASSWORD",
  birth: {
    month: "JANUARY",
    year: "1980"
  },
  multiple: ['a', 'b', 'c']
}
*/

License

MIT