I'm new to javascript, and still learning.
So, I have below input of json file
{
    "m_documents": {
        "documents": {
            "document": {
                "document": {
                    "id": [9286154, 9286163, 9306789, 9439618, 9513434, 9758081, 9866904, 9971257, 11229157, 11321316, 11323467, 11446058, 11481394, 11503220, 11522976, 11546733, 11571103, 11582740],
                    "created": ["2018-12-27", "2018-12-27", "2018-12-27", "2019-01-21", "2019-02-01", "2019-03-29", "2019-04-23", "2019-05-20", "2019-11-15", "2019-12-11", "2019-12-11", "2019-12-24", "2020-01-07", "2020-01-09", "2020-01-10", "2020-01-13", "2020-01-15", "2020-01-17"],
                    "name": ["H70", "H70", "H70", "H70", "H82", "H71", "H71", "H71", "H71", "H72", "H70", "H70", "H70", "H70", "H70", "H70", "H72", "H70"],
                    "type": ["H041", "H041", "H041", "H041", "H064", "H064", "H064", "H064", "H064", "H047", "H041", "H041", "H041", "H041", "H041", "H041", "H047", "H041"]
                },
                "case": {
                    "name": ["V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01", "V01"],
                    "work_type": {
                    "group": ["ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC"],
                    "id": ["1.2.4278465", "1.2.4278465", "1.2.4295143", "1.2.4363157", "1.2.4392970", "1.2.4494342", "1.2.4546187", "1.2.4592022", "1.2.5088384", "1.2.5150085", "1.2.5162736", "1.2.5236182", "1.2.5249537", "1.2.5269876", "1.2.5287418", "1.2.5305056", "1.2.5317864", "1.2.5327907"]
                    }
                }
            }
        }
    }
}
I would like to convert like this,
   {
        "documents": {
            "document": [{"id": "9286154", "created": "2018-12-27", "name": "H70", "type": "H041"}],
            "case": [{"id": "V01" , "work_type": {"group": "ABC", "id": "1.2.4278465"}}]
        },
        "documents": {
            "document": [{"id": "9286163", "created": "2018-12-27", "name": "H70", "type": "H041"}],
            "case": [{"name": 0, "work_type": {"group": "ABC", "id": "1.2.4278465"}}]
        },
   "documents": {...}   
    }
How can I achieve this? I did like this, passing input to this function, but for some reason, case type is not working
function Entries(entries) {
    var Result = [];
    if (entries.length) {
        var arrayMode = entries[0].value.length !== undefined;
        var itemCount = arrayMode ? entries[0].value.length : 1;
        for (var i = 0; i < itemCount; i++) {
            var zippedObject = {};
            for (var j = 0; j < entries.length; j++) {
                zippedObject[entries[j].key] = arrayMode ? entries[j].value[i] : entries[j].value;
            }
            Result.push(zippedObject);
        }
    }
    return Result;
}
This input data has been edited based on old response. I hope this time the data and expected outcomes make sense. I know there must be nicer and shorter way to execute it. Keys can be duplicated.
 
    