Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Ability to configure custom JSON.parse reviver for the HttpClient #21079

Copy link
Copy link
@bygrace1986

Description

@bygrace1986
Issue body actions

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:

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: common/httpIssues related to HTTP and HTTP ClientIssues related to HTTP and HTTP ClientfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesstate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.