After receiving the JSON data shown below, I have a specific model in mind for deserialization:
{"results":
{"data": {
"id":"93cba9bd-2969-3214-b26f-7f42d20241a4",
"first_name":"PSU",
"last_name":"Bot",
"profile": {
"data":{"about":"i am so happy",}
}
}
}
The desired model is as follows:
export class Person extends BaseModel {
first_name: string;
last_name: string;
profile: DataType<Profile>;
}
The aim is to have the profile property without the nested data element.
To achieve this, I am looking into constructing a generic DataType. Here's my initial attempt:
export class DataType<T> {
public constructor(arg: T) {
console.log(arg);
return new arg.data;
}
}
I'm wondering if this falls under generic type territory or should be treated as an object (class) similar to the example above. Any insights on this would be appreciated.