I need to convert "flat object" like this (input data):

```
{
   'prop1': 'value.1',
   'prop2-subprop1': 'value.2.1',
   'prop2-subprop2': 'value.2.2',
}

```

to immersion object like this (output data):

```
{
   'prop1': 'value.1',
   'prop2': {
      'subprop1': 'value.2.1',
      'subprop2': 'value.2.2'
   }
}

```

Of course solution have to be prepare for no-limit deep level.

My solution does not work:

```
var inputData = {
   'prop1': 'value.1',
   'prop2-subprop1': 'value.2.1',
   'prop2-subprop2': 'value.2.2',
};    

function getImmersionObj(input, value) {
   var output = {};

   if ($.type(input) === 'object') { // first start
      $.each(input, function (prop, val) {
         output = getImmersionObj(prop.split('-'), val);
      });
   } else if ($.type(input) === 'array') { // recursion start
      $.each(input, function (idx, prop) {
         output[prop] = output[prop] || {};
         output = output[prop];
      });
   }

   return output;
}

console.log(getImmersionObj(inputData)); // return empty object

```

Can you help me find the problem in my code or maybe you know another one, better algorithm for conversion like my?