When I cast to Class Object extra values from Json pop up when I Log the Class object.
This is the Class Model
export class PersonModel {
_index : string;
_type : string;
_id : string;
demo : "test";
_score : number;
_source : {
name : string;
age : number;
salary:number;
details :{
year: number;
education:{
score:number;
};
};
};
}
This is final output I get when I print the class object.Its not even printing the demo field from class.
{
"_index":"person",
"_type":"single",
"_id":"AV-Migit0bfajafmy3",
"_version":2,
"found":true,
"_source":{
"name":"hyd",
"salary":600000,
"age":27
}
I wanted to know how to convert the Json into Class Object so that I can fill the details field and save it to database.
Here is the conversion code
getPerson (id : string): Observable<PersonModel> {
const url = `${this.url}/${id}`;
return this.http.get< PersonModel >(url);
}