The backend is sending me a JSON data structure that resembles the following:
[{
"schedulingId": "7d98a02b-e14f-43e4-a8c9-6763ba6a5e76",
"schedulingDateTime": "2019-12-28T14:00:00",
"registrationDateTime": "2019-12-24T16:47:34",
"doctorViewModel": {
"doctorId": "a49d9534-65a6-4730-ac45-4dc2f91165e0",
"doctorName": "Ana"
},
"personViewModel": {
"personId": "3607c475-e287-4e83-85e6-a46f4a0116d6",
"personName": "João",
"birthDate": "1970-09-18T00:00:00"
},
"consultaViewModel": null
}]
My goal is to parse this JSON into a Scheduling object with date format 'dd/MM/yyyy hh:MM:ss':
export interface Scheduling {
schedulingId : string;
schedulingDateTime : Date;
registrationDateTime : Date;
person : Person;
doctor : Doctor;
consulta? : Consulta;
}
export interface Person {
personId : string;
personName : string;
birthDate : Date;
}
export interface Doctor {
doctorId : string;
doctorName : string;
}
export interface Consulta {
consultaId : string;
consultaDateTime : Date;
}
After calling my get method, I need to figure out how to deserialize the JSON properly:
this.httpClient.get<Scheduling>(`${applicationUrl}/scheduling/${date}`);