Skip to content

Instantly share code, notes, and snippets.

@deyvicode
Last active March 30, 2021 18:01
Show Gist options
  • Save deyvicode/6197984457f7ea8decf6868be0f9fc76 to your computer and use it in GitHub Desktop.
Save deyvicode/6197984457f7ea8decf6868be0f9fc76 to your computer and use it in GitHub Desktop.
Convert form data to a JSON object
const formDataToJson = form => {
let unindexed_array = form.serializeArray();
let indexed_array = {};
$.map(unindexed_array, (n, i) => {
indexed_array[n['name']] = n['value'];
});
return indexed_array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment