-4
{
   "user": {
       "name": "Test",
       "gender": "m",
       "birthday": "05.05.2014",
    },
    "work" : "programmer"
}

To parse the data from the form we use it:

angular.forEach($scope.profile, function(value, key){

With an array of forms comes in a format:

  key = {user_name: "Test"}

To convert to: key = { user : {name: "Test"}}

angular.forEach($scope.profile, function(value, key){
    var keyArray = key.split('.');
    if (keyArray.length > 1) {
       ????
    } else {
        res[key] = value.$modelValue;
    }
}, log);
Ahmad Dwaik 'Warlock'
  • 5,953
  • 5
  • 34
  • 56

1 Answers1

1

You can use AngularJS functions for this

Convert json to array:

var array = angular.fromJson(yourJson);

Convert array to JSON:

var json = angular.toJson(yourArray);
Dieterg
  • 16,118
  • 3
  • 30
  • 49