-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Closed
Labels
area: common/httpIssues related to HTTP and HTTP ClientIssues related to HTTP and HTTP ClientfeatureIssue that requests a new featureIssue that requests a new featurestate: has PR
Milestone
Description
I'm submitting a...
[x] Feature request
Current behavior
With the new HttpClient if the responseType is set to 'json' or if it is not set (defaulted to 'json') then the JSON is parsed before being returned to the consuming code. Here is the source-code where the JSON.parse occurs:
angular/packages/common/http/src/xhr.ts
Line 189 in 20e1cc0
| body = body !== '' ? JSON.parse(body) : null; |
Expected behavior
A reviver function can be configured that the HttpClient will use when parsing json. As far as the implementation, maybe an injection token can be exposed which developers can use to provide a reviver function.
What is the motivation / use case for changing the behavior?
Dates are deserialized as strings with JSON.parse. It is convenient to have dates serialized to Date objects globally via a centralized service using a reviver.
CD-UNCC, bygrace1986, TimStrunck, khrice, jraadt and 94 more
Metadata
Metadata
Assignees
Labels
area: common/httpIssues related to HTTP and HTTP ClientIssues related to HTTP and HTTP ClientfeatureIssue that requests a new featureIssue that requests a new featurestate: has PR