Loop object get valur from input and change object value

I have a multidimensional object with several variable levels.
For each value corresponds an input whose name is in the form “par1-par1_1-c1-type” (for example).
I want to iterate over the object to get the value of the input and update the value of the object.

Part of the object:

par1
    nc = 0
    par1_1
        c1
            type = ""
            date
                m = ""
                y = ""
        c2
            type = ""
            date
                m = ""
                y = ""
    par1_2
        c1 = ""
        c2 = ""
    par1_3
        c1 = ""
        c2 = ""

par2
    nc
    par2_1
        c1 = ""
        c2 = ""
    par2_2
        c1 = ""
        c2 = ""
    par2_3
        c1 = ""
        c2 = ""
    par2_4
        c1
            nc = ""
            list
                type = ""
                mtt = ""
        c2
            nc
            list
                type = ""
                mtt = ""

On submit i do :

var obj;
function submit() {
    datasloop(obj,"");
}

function datasloop(arr, parname) {
    for(let name in arr) {
        let fullname;
        if(parname == undefined || parname == "") fullname = name;
        else fullname = parname+"-"+name;
        if(IsObject(arr[name])) {
            datasloop(arr[name],fullname);
        } else {
            var _i = _form.elements[fullname];
            if(_i) {
                console.log(fullname+" = "+_i.value);
            }
        }
    }
}

In the console I have “par1-par1_1-c1-type = thevalue” and I would like to put this value in the object: obj[‘par1’][‘par1_1’][‘c1’][‘type’ ] = thevalue