Skip to content

proposal: encoding/json: remove EscapeInvalidUTF8 #74551

Closed
@dsnet

Description

@dsnet

Proposal Details

With the possible acceptance of #71497, there are many legacy options added to v1 "encoding/json" to preserve v1 semantics in v2. One such option is EscapeInvalidUTF8, which is a highly esoteric option to escape the Unicode replacement character in the presence of invalid UTF-8, rather than using the replacement character itself, which is more natural (and what the character exists for).

I propose just changing the default v1 behavior to do the same thing as v2 and delete the EscapeInvalidUTF8 option. I don't really see a particular usefulness to it.

For prior precedence, we have actually changed the low-level formatting of JSON in the past (and pretty substantially so), so this should be an acceptable change that's permitted by the Go compatibility document:

I don't anticipate any more low-level syntactic changes like these anymore after this last one, since v2 outputs according to RFC 8785 by default (except for guarantees on object ordering).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions