Skip to content

parseJson option #1274

@kirillgroshkov

Description

@kirillgroshkov

As discussed there: sindresorhus/ky#254 (comment)

Option should allow to pass a user-function that will perform JSON parsing.

Use cases:

  1. Use bourne to mitigate the hyped prototype pollution.
  2. Parse JSON with reviver

Example API:

type ParseJsonFunction = <OUTPUT = unknown>(text: string) => OUTPUT

const myGot = got.extend({
  parseJson: text => bourne(text),
})

Should be available both via .extend() and as an option to each request.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions