JSFiddle - React, Tailwind, and code Playground
JavaScript
var myObject = {
"Apps": [{
"Name": "app1",
"id": "1",
"groups": [{
"id": "1",
"name": "test group 1",
"category": "clinical note",
"author": "RRP"
}, {
"id": "2",
"name": "test group 2",
"category": "clinical image",
"author": "LKP"
}, {
"id": "3",
"name": "test group 3",
"category": "clinical document",
"author": "RRP"
}, {
"id": "4",
"name": "test group 4",
"category": "clinical note",
"author": "John"
}]
}]
}
var groups = myObject.Apps[0].groups;
var authors = {};
for(var i = 0; i < groups.length; i++) {
var group = groups[i];
if(typeof authors[group.author] === "undefined") {
authors[group.author] = [];
}
authors[group.author].push({
id: group.id,
name: group.name,
category: group.category
});
}
console.log(authors);