How to get nested json object for given form details?

I am trying to get json object and I have tried it but it's coming like in a plain json format, but I need it like in something nested json format like what I explained in the fiddle. How can I achieve it ? Please help me and thanks in advance.

Answers 1

  • $scope.serialize = function($event){
    var testing = [
        {'Fname':$scope.formData.Fname},
      {'Lname':$scope.formData.Lname},
      {'Mname':$scope.formData.Mname},
      {'Education':$scope.formData.Education},
      {'Age':$scope.formData.Age},
    ];
    $scope.formData = {
    'testing' : testing, 
    'University' : $scope.formData.University,
    'Companies' : $scope.formData.companies,
    };
    console.log($scope.formData)
    alert(JSON.stringify($scope.formData))
    console.log(JSON.stringify($scope.formData));
    $event.preventDefault()
    

    }

    use this code.


Related Articles