Having recently started working with Typescript, I have a JSON object that needs to be mapped to a generic interface. However, my initial attempt at creating the interface seems to be incorrect. I need assistance in constructing a generic interface or class that can properly handle the mapping of the JSON object below.
JSON Object
"parentValue": {
"childValue1": {
"resource": "childValue1",
"application": "childValue1",
"permissions": [
"READ"
],
"attributeConstraints": {},
"attributeConstraintsCount": 0
},"childValue2": {
"resource": "childValue2",
"application": "childValue2",
"permissions": [
"READ"
],
"attributeConstraints": {},
"attributeConstraintsCount": 0
},
"childValue3": {
"resource": "childValue3",
"application": "childValue3",
"permissions": [
"READ"
],
"attributeConstraints": {},
"attributeConstraintsCount": 0
}
}
Typescript Interface
interface ParentValue{
childValue: ChildValue<T>
}
export interface ChildValue<T>{
childDetails: ChildDetails
}
export ChildDetails{
resource: string;
application: string;
permissions: string[];
attributeConstraints: AttributeConstraints;
attributeConstraintsCount: number;
}