I have model MyObejct like this in client:
class MyObject{
id: number;
name: string;
active: boolean;
}
And the http response json data like this:
[
{
id: "1",
name: "object1",
active: "true",
}
]
The http response is key-value pair, and all the value type is string. So how can I map the http response to 'MyObject' type. The http get function is like this:
getMyObejct(name: string): Observable<MyObject> {
const url = this.url + 'name/' + name;
return this.http.get<MyObject>(url); // This is part I'm confused
}
getAllObjects(): Observable<MyObject[]> {
return this.http.get<MyObject>(this.url); // How to map this reponse to MyObject
}
The http response values are all string type, but MyObject has types number and boolean. How can I do that?