When I receive a JSON response from a Java server, the structure looks like this:
{
"summary": {
},
"runs": {
"key_1": {
"object_1": {
},
"object_2": {
}
},
"key_2": {
"object_1": {
},
"object_2": {
}
}
}
}
The service function is defined as follows:
public getDetailsV2(id: number): Observable<MyClass> {
return this.httpClient.get<SimulationDetailedResponseV2>(
'url_to_endpoint'
);
}
Calling the service function like this:
this.service.getDetailsV2(1).subscribe({
next: (details) => {
this.details = details;
}
});
However, when I try to use map methods on this.details
, I encounter errors. For example, attempting to retrieve the first entry with:
this.details.runs.entries().next().value;
results in:
ERROR TypeError: this.details.runs.entries is not a function
The MyClass class is structured like this:
export class MyClass {
runs: Map<string, AnotherObject>;
}
Why isn't the response.runs automatically converted to a map? How can I manually convert it?