Created
August 12, 2013 22:58
-
-
Save countable/6216141 to your computer and use it in GitHub Desktop.
Convert HTML form data to JSON.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.serializeObject = -> | |
| o = {} | |
| a = @serializeArray() | |
| $.each a, -> | |
| if o[@name] | |
| o[@name] = [o[@name]] unless o[@name].push | |
| o[@name].push @value or "" | |
| else | |
| o[@name] = @value or "" | |
| o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment