Skip to content

feature request: Optionally enabling/disabling HTMLEscaping #83

@nesbyte

Description

@nesbyte

First off, thank you for an incredibly useful and consise package. This request is open ended with maintainers to decide if it fits the vision of the package.

Description

Allow for the HTML escaping for JSON to be enabled/disabled through a separate config parameter. Default should still be to have HTML escaped as per default in the std json package.

Motivation

The null package currently does not allow for the HTML to not be escaped at marshalling, due to the direct use of json.Marshal in the custom Marshal implementations, which is unexpected when marshalling a larger response with a null.String present and with HTML escaping disabled.

Proposed solution

Although potentially ugly - a global package config could initially be optionally set by users to disable (or explicitly enable) HTML Escaping.
If this idea is accepted, I am happy to create a PR.

  1. This feature would not break backwards compatibility
  2. It would not cause feature bloat as the std json package only allows SetEscapeHTML() as an optional config in it's encoder
  3. It would only impact string types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions