Как динамически определить иерархию в JSON, чтобы использовать ее в библиотеке JS OrgChart?
Мне нужно создать OrgChart, который будет принимать файл JSON локально в качестве входных данных и отображать его как динамическую оргструктуру с использованием библиотек JavaScript. Проблема в том, что JSON не имеет четкой иерархии, определенной как Id и Pid или определение parent-child, которое требуется в большинстве библиотек, доступных онлайн. Структура JSON показана ниже:
{
"programList": [{
"programId": "randomID1",
"version": 1,
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"name": "name",
"defaultName": "name",
"description": "description",
"populationId": "randomID63",
"type": "rtype",
"startDtTm": "time-stamp",
"endDtTm": "time-stamp",
"priority": "priorities",
"dataType": "datatype",
"links": [{
"programLinkId": "randomID2",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"linkURL": "location",
"linkType": "RULES"
}],
"measures": [{
"programMeasureId": "randomID3",
"createdDtTm": "2time-stamp",
"updatedDtTm": "2time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID4",
"createdDtTm": "time-stamp",
"updatedDtTm": "2time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
},{
"programMeasureId": "randomID17",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "Pname",
"defaultName": "name",
"description": "description",
"defaultDescription": "description.",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}],
"datasets": [],
"ruleNamespaces": ["name"],
"ruleFactTypes": ["TYPE"],
"published": true,
"requiredPrograms": [],
"settings": {
"customSettings": [{
" Key": "KEY",
"value": "VALUE"
}]
},
"programGroupIds": ["randomID18"],
"programContextToConceptMappings": [{
"contextId": "randomID",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID19",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID20",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID21",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID22",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID23",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID24",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID25",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID26",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID27",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID28",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}]
}, {
"programId": "randomID29",
"version": 3,
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"name": "name",
"defaultName": "name",
"description": "description.",
"defaultDescription": "description",
"populationId": "randomID128",
"type": "rtype",
"startDtTm": "time-stamp",
"endDtTm": "time-stamp",
"priority": "priorities",
"dataType": "datatype",
"links": [{
"programLinkId": "randomID30",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"linkURL": "location",
"linkType": "RULES"
}],
"measures": [{
"programMeasureId": "randomID31",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID35",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description.",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
},{
"programMeasureId": "randomID46",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID47",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID48",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description.",
"defaultDescription": "description.",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "datam",
"measureStratifications": []
}, {
"programMeasureId": "randomID49",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}],
"datasets": [],
"ruleNamespaces": ["name"],
"ruleFactTypes": ["Types"],
"published": true,
"requiredPrograms": [],
"settings": {
"customSettings": [{
" Key": "KEY",
"value": "VALUE"
}]
},
"programGroupIds": ["randomID50"],
"programContextToConceptMappings": [{
"contextId": "randomID51",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID52",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID53",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID54",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID55",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID56",
"contextVersion": null,
"conceptAliases": ["TMULTIPLE ALIASES"]
}, {
"contextId": "randomID57",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID58",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID59",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID60",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID61",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}]
}, {
"programId": "randomID62",
"version": 2,
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"populationId": "6randomID129",
"type": "rtype",
"startDtTm": "time-stamp",
"endDtTm": "time-stamp",
"priority": "priorities",
"dataType": "datatype",
"links": [{
"programLinkId": "randomID121",
"createdDtTm": "2time-stamp",
"updatedDtTm": "time-stamp",
"linkURL": "location",
"linkType": "RULES"
}],
"measures": [{
"programMeasureId": "randomID120",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "names",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID118",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "Tdescription",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID117",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID106",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "Data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID105",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "Data",
"defaultShortDisplay": "Data",
"measureStratifications": []
}],
"datasets": [],
"ruleNamespaces": ["name"],
"ruleFactTypes": ["type"],
"published": true,
"requiredPrograms": [],
"settings": {
"customSettings": [{
" Key": "key",
"value": "values"
}]
},
"programGroupIds": ["6randomID104"],
"programContextToConceptMappings": [{
"contextId": "randomID103",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID102",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID101",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID100",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID99",
"contextVersion": null,
"conceptAliases": ["NMULTIPLE ALIASES"]
}, {
"contextId": "randomID98",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID97",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}]
}, {
"programId": "randomID95",
"version": 4,
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"populationId": "randomID96",
"type": "rtype",
"startDtTm": "time-stamp",
"endDtTm": "time-stamp",
"priority": "priorities",
"dataType": "datatype",
"links": [{
"programLinkId": "randomID94",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"linkURL": "location",
"linkType": "RULES"
}],
"measures": [{
"programMeasureId": "randomID93",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name0",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID92",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "Tdescription",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "0randomID91",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
},
{
"programMeasureId": "randomID84",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description.",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID83",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}, {
"programMeasureId": "randomID82",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"defaultDescription": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
},
{
"programMeasureId": "arandomID72",
"createdDtTm": "time-stamp",
"updatedDtTm": "time-stamp",
"fullyQualifiedName": "name",
"name": "name",
"defaultName": "name",
"description": "description",
"measureType": "rtype",
"measureEntityTypes": ["mtype"],
"measureOutcomeType": "BOOLEAN",
"pol": true,
"sen": false,
"shortDisplay": "data",
"defaultShortDisplay": "data",
"measureStratifications": []
}],
"datasets": [],
"ruleNamespaces": ["name"],
"ruleFactTypes": ["types"],
"published": true,
"requiredPrograms": [],
"settings": {
"customSettings": [{
" Key": "keys",
"value": "values"
}]
},
"programGroupIds": ["randomID71"],
"programContextToConceptMappings": [{
"contextId": "randomID130",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "7randomID66",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID65",
"contextVersion": null,
"conceptAliases": ["MULTIPLE ALIASES"]
}, {
"contextId": "randomID64",
"contextVersion": null,
"conceptAliases": ["SMULTIPLE ALIASES"]
}]
}]
}
Буду признателен за ваши предложения о том, как это сделать.