Skip to content

Instantly share code, notes, and snippets.

@countable
Created August 12, 2013 22:58
Show Gist options
  • Save countable/6216141 to your computer and use it in GitHub Desktop.
Save countable/6216141 to your computer and use it in GitHub Desktop.
Convert HTML form data to JSON.
$.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