I am working with a somewhat dynamic AngularJS form. In other words, I am able to add rows of input fields, etc. So my approach was to start with a $scope.formData
$scope.formData
function replacer(key, value) { if (value == "" || value == null) { return undefined; } return value; } var foo = {foundation: "", model: {year: 2015, price:null}, week: 45, transport: "car", month: 7}; foo = JSON.stringify(foo, replacer); foo =JSON.parse(foo); console.log(foo);