I am usign JSTree to show tree structure. Now I need to show selected parent/child when edit a record. For this I've below json that is required json to show selected parent/child node in tree.
varpathArray={
  "func_extensions_job": [
    {
      "CodiacSDK.NewModule.dll;extensionCreatePre;": [
        {
          "CodiacSDK.NewModule.dll;extensionInquirePost;": [
          ]
        }
      ]
    }
  ]
};
But its static json and I need dynamic json to convert like above. Below is the json that I get via API response. Now I need to add an empty array at last value.
{"func_extensions_job":[{"CodiacSDK.NewModule.dll;extensionCreatePre;":[{"CodiacSDK.NewModule.dll;extensionExecutePost;":["CodiacSDK.PythonWrapper.dll;UnitValues::extensionExecutePre;"]}]}]}
I've this
["CodiacSDK.PythonWrapper.dll;UnitValues::extensionExecutePre;"]
That I need to convert in this
[{"CodiacSDK.NewModule.dll;extensionInquirePost;":[]}]
So is there any way that I can do it.
I am using below function to generate my json array without empty object
var path = $("#testing").jstree().get_path($("#testing").jstree("get_selected", true)[0], '{/}').split('{/}');
            var resJson = {};
            console.log(JSON.stringify(resJson));
            for (var j = path.length; j > 1; j--) {
                //console.log(path[j - 2]);
                if (path[j - 2] && !Object.keys(resJson).length) {
                    resJson[path[j - 2]] = [path[j - 1]];
                } else {
                    var temp = resJson;
                    resJson = {};
                    resJson[path[j - 2]] = [temp];
                }
            }
Any help is appreciated. Thanks in advance.
 
    