I'm new to Jquery , can anyone help me out or tell me how to handle this, i tried with some other examples but i didn't get them.
var arr = [
{ PARENTNODE: "Resource Management", CHILDNODE: "ManPower", OPERATIONNAME: "Update" },
{ PARENTNODE: "Resource Management", CHILDNODE: "Manpower", OPERATIONNAME: "View" },
{ PARENTNODE: "Resource Management", CHILDNODE: "ManPower", OPERATIONNAME: "Delete" },
{ PARENTNODE: "Resource Management", CHILDNODE: "Manpower", OPERATIONNAME: "Insert" },
{ PARENTNODE: "Resource Management", CHILDNODE: "Vehicles", OPERATIONNAME: "Update" },
{ PARENTNODE: "Resource Management", CHILDNODE: "Vehicles", OPERATIONNAME: "View" },
{ PARENTNODE: "Resource Management", CHILDNODE: "Vehicles", OPERATIONNAME: "Insert" },
{ PARENTNODE: "Resource Management", CHILDNODE: "Vehicles", OPERATIONNAME: "Delete" },
{ PARENTNODE: "Contacts", CHILDNODE: "Customers", OPERATIONNAME: "Update" },
{ PARENTNODE: "Contacts", CHILDNODE: "Customers", OPERATIONNAME: "View" },
{ PARENTNODE: "Contacts", CHILDNODE: "Customers", OPERATIONNAME: "Insert" },
{ PARENTNODE: "Contacts", CHILDNODE: "Customers", OPERATIONNAME: "Delete" }
],
I need to convert this json data to nested data like this,
[{
text: "Resource Management",
items: [{
text: "Manpower",
items: [{
text: "Update",
}, {
text: "Delete",
}, {
text: "Insert",
}, {
text: "View",
}]
}, {
text: "Vehicles",
items: [{
text: "Update",
}, {
text: "Delete",
}, {
text: "Insert",
}, {
text: "View",
}]
}]
}, {
text: "Contacts",
items: [{
text: "Manage Customers",
items: [{
text: "Update",
}, {
text: "Delete",
}, {
text: "Insert",
}, {
text: "View",
}]
}]
}]
Thanks in advance! Please help me out.