У меня проблема с преобразованием плоского массива, и я могу использовать вашу помощь!
В настоящее время формат данных выглядит следующим образом:
[
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": null,
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 6,
"OVERALL_MARKET_VALUE": 1
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 1,
"OVERALL_MARKET_VALUE": 8
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_1",
"MARKET_VALUE": 10,
"OVERALL_MARKET_VALUE": 5
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_2",
"MARKET_VALUE": 5,
"OVERALL_MARKET_VALUE": 3
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 5,
"OVERALL_MARKET_VALUE": 10
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_1",
"MARKET_VALUE": 6,
"OVERALL_MARKET_VALUE": 1
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_2",
"MARKET_VALUE": 10,
"OVERALL_MARKET_VALUE": 5
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": null,
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 6,
"OVERALL_MARKET_VALUE": 1
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 1,
"OVERALL_MARKET_VALUE": 8
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_1",
"MARKET_VALUE": 10,
"OVERALL_MARKET_VALUE": 5
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_2",
"MARKET_VALUE": 5,
"OVERALL_MARKET_VALUE": 3
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 5,
"OVERALL_MARKET_VALUE": 10
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_1",
"MARKET_VALUE": 6,
"OVERALL_MARKET_VALUE": 1
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_2",
"MARKET_VALUE": 10,
"OVERALL_MARKET_VALUE": 5
}
]
И я надеюсь закончить с результат, подобный этому:
[
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": null,
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 6,
"OVERALL_MARKET_VALUE": 1,
"children": [
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 1,
"OVERALL_MARKET_VALUE": 8,
"children": [
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_1",
"MARKET_VALUE": 10,
"OVERALL_MARKET_VALUE": 5
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_2",
"MARKET_VALUE": 5,
"OVERALL_MARKET_VALUE": 3
},
]
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 5,
"OVERALL_MARKET_VALUE": 10,
"children": [
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_1",
"MARKET_VALUE": 6,
"OVERALL_MARKET_VALUE": 1
},
{
"MASTER_ACCOUNT_NAME": "MAIN_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_2",
"MARKET_VALUE": 10,
"OVERALL_MARKET_VALUE": 5
},
]
},
]
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": null,
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 6,
"OVERALL_MARKET_VALUE": 1,
"children": [
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 1,
"OVERALL_MARKET_VALUE": 8,
"children": [
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_1",
"MARKET_VALUE": 10,
"OVERALL_MARKET_VALUE": 5
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "MAIN_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_2",
"MARKET_VALUE": 5,
"OVERALL_MARKET_VALUE": 3
},
]
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": null,
"MARKET_VALUE": 5,
"OVERALL_MARKET_VALUE": 10,
"children": [
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_1",
"MARKET_VALUE": 6,
"OVERALL_MARKET_VALUE": 5
},
{
"MASTER_ACCOUNT_NAME": "SECOND_ENTITY",
"SUB_ACCOUNT_NAME": "SECOND_ACCOUNT",
"TERTIARY_ACCOUNT_NAME": "TERTIARY_ACCOUNT_2",
"MARKET_VALUE": 10,
"OVERALL_MARKET_VALUE": 5
},
]
},
]
},
]
Извините за огромный размер! Раздел верхнего уровня будет MASTER_ACCOUNT_NAME, уровень после этого будет SUB_ACCOUNT_NAME, а элементы самого низкого уровня - TERTIARY_ACCOUNT_NAME.
Я делал многочисленные попытки сделать это с loda sh и vanilla javascript, но мне пришлось признают, что манипулирование данными на самом деле не моя область мастерства, и я тяжело бороться с этим!
заранее спасибо за любую помощь вы можете предоставить мне! * * 1013