I need assistance with converting a JSON object into the equivalent generic type in TypeScript.
The JSON object I have contains dynamic keys such as applications
and permissions
. The keys inside applications, like application_management
and user_management
, can also be dynamic. Similarly, the keys inside permissions, such as create_application
, delete_application
, update_application
, etc., can be dynamic as well.
I attempted to accomplish this using an interface but unfortunately faced challenges. Could someone please help me resolve this issue?
{
"id": 1,
"isSuperAdmin": true,
"firstName": "Oleksii",
"lastName": & "Michael",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="452429203d3505352a2c2b31773220276b262a28">[email protected]</a>",
"gender": "male"",
"dob": "1990-01-01",
"photo": null,
"status": "ACTIVE",
"roles": [
{
"id": 1,
"slug": "Head of Department-(Account Management-Network-P2W North America)"
},
{
"id": 2,
"slug": "Team Lead-(Account Management-Network-P2W North America)"
},
{
"id": 3,
"slug": "Employee-(Account Management-Network-P2W North America)"
}
],
"applications": {
"application_management": {
"id": 41,
"slug": "application_management",
"appName": "Application Management",
"status": "ACTIVE",
"appType": "CODED",
"appUrl": "application-management",
"appIcon": "http://api.chromosome-studio.com/uploads/applications/application.png",
"permissions": {
"delete_application": {
"id": 3,
"action": "Delete Application",
"slug": "delete_application",
"level": "all"
},
"update_application": {
"id": 2,
"action": "Update Application",
"slug": "update_application",
"level": "all"
},
"create_application": {
"id": 1,
"action": "Create Application",
"slug": "create_application",
"level": "all"
}
}
},
"user_management": {
"id": 42,
"slug": "user_management",
"appName": "User Management",
"status": "ACTIVE",
"appType": "CODED",
"appUrl": "user-management",
"appIcon": "http://api.chromosome-studio.com/uploads/applications/users.png",
"permissions": {
"create_user": {
"id": 4,
"action": "Create User",
"slug": "create_user",
"level": "all"
}
}
}
}