У меня есть этот Json из бэкэнда, который не управляет иерархией в запросе, и я хотел бы заказать его с xslt
{
"status": {
"code": 200
},
"result": [{
"documentTypeId": 1,
"name": "Contatto cliente",
"description": "Contatto cliente",
"menuKey": "customerContact",
"processId": 1,
"eventId": 1,
"phase": "presale",
"registryRoleId": 1
}, {
"documentTypeId": 2,
"name": "Richiesta da cliente",
"description": "Richiesta da cliente",
"menuKey": "customerRequest",
"processId": 1,
"eventId": 2,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 3,
"name": "Offerta a cliente",
"description": "Offerta a cliente",
"menuKey": "customerOffer",
"processId": 1,
"eventId": 3,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 4,
"name": "Ordine da cliente",
"description": "Ordine da cliente",
"menuKey": "customerOrder",
"processId": 1,
"eventId": 4,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 5,
"name": "Fornitura merce a cliente",
"description": "Fornitura merce a cliente",
"menuKey": "customerGoodsSupply",
"processId": 1,
"eventId": 5,
"phase": "sale",
"registryRoleId": 2
}, {
"documentTypeId": 6,
"name": "Fornitura servizio a cliente",
"description": "Fornitura servizio a cliente",
"menuKey": "customerServicesSupply",
"processId": 1,
"eventId": 6,
"phase": "sale",
"registryRoleId": 2
}, {
"documentTypeId": 7,
"name": "Fornitura consulenza a cliente",
"description": "Fornitura consulenza a cliente",
"menuKey": "customerConsultingSupply",
"processId": 1,
"eventId": 7,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 8,
"name": "Fattura a cliente",
"description": "Fattura a cliente",
"menuKey": "customerInvoice",
"processId": 1,
"eventId": 8,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 9,
"name": "Fattura finale",
"description": "Fattura finale a cliente",
"menuKey": "finalCustomerInvoice",
"processId": 1,
"eventId": 9,
"phase": "sale",
"registryRoleId": 2
}, {
"documentTypeId": 11,
"name": "Chiusura contatto cliente",
"description": "Chiusura contatto cliente",
"menuKey": "customerContactClose",
"processId": 1,
"eventId": 11,
"phase": "presale",
"registryRoleId": 1
}]
}
Я хотел бы сгруппировать по "фаза" (сначала «предварительная продажа», а затем закажите его по «documentTypeId», чтобы получить что-то вроде этого:
{
"status": {
"code": 200
},
"result": [{
"documentTypeId": 1,
"name": "Contatto cliente",
"description": "Contatto cliente",
"menuKey": "customerContact",
"processId": 1,
"eventId": 1,
"phase": "presale",
"registryRoleId": 1
},
{
"documentTypeId": 11,
"name": "Chiusura contatto cliente",
"description": "Chiusura contatto cliente",
"menuKey": "customerContactClose",
"processId": 1,
"eventId": 11,
"phase": "presale",
"registryRoleId": 1
},
{
"documentTypeId": 2,
"name": "Richiesta da cliente",
"description": "Richiesta da cliente",
"menuKey": "customerRequest",
"processId": 1,
"eventId": 2,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 3,
"name": "Offerta a cliente",
"description": "Offerta a cliente",
"menuKey": "customerOffer",
"processId": 1,
"eventId": 3,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 4,
"name": "Ordine da cliente",
"description": "Ordine da cliente",
"menuKey": "customerOrder",
"processId": 1,
"eventId": 4,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 5,
"name": "Fornitura merce a cliente",
"description": "Fornitura merce a cliente",
"menuKey": "customerGoodsSupply",
"processId": 1,
"eventId": 5,
"phase": "sale",
"registryRoleId": 2
}, {
"documentTypeId": 6,
"name": "Fornitura servizio a cliente",
"description": "Fornitura servizio a cliente",
"menuKey": "customerServicesSupply",
"processId": 1,
"eventId": 6,
"phase": "sale",
"registryRoleId": 2
}, {
"documentTypeId": 7,
"name": "Fornitura consulenza a cliente",
"description": "Fornitura consulenza a cliente",
"menuKey": "customerConsultingSupply",
"processId": 1,
"eventId": 7,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 8,
"name": "Fattura a cliente",
"description": "Fattura a cliente",
"menuKey": "customerInvoice",
"processId": 1,
"eventId": 8,
"phase": "sale",
"registryRoleId": 1
}, {
"documentTypeId": 9,
"name": "Fattura finale",
"description": "Fattura finale a cliente",
"menuKey": "finalCustomerInvoice",
"processId": 1,
"eventId": 9,
"phase": "sale",
"registryRoleId": 2
}
]
}
Я буду использовать этот XSLT в посреднике XSLT в WSO2 ei. Спасибо В качестве альтернативы, могу ли я использовать JavaScript-код для этой манипуляции?