formdata to json jquery code example

Example 1: how take values from JSON.stringify($('form').serialize())

1 var formData = $('#form').serializeObject();
2 $.extend(formData, { Contacts : myContacts});
3 $.extend(formData, { Address : myAddress});
4 var result = JSON.stringify(formData);
5

Example 2: FormData to json

var object = {};
formData.forEach(function(value, key){
    object[key] = value;
});
var json = JSON.stringify(object);

// Or ES6 arrow function
var object = {};
formData.forEach((value, key) => object[key] = value);
var json = JSON.stringify(object);