Skip to content

proposal: encoding/json/v2: add format:0xhex for []byte #75492

@lmittmann

Description

@lmittmann

Proposal Details

json/v2 already has the format option format:hex for []byte types. However hex bytes are often encoded with a 0x prefix. This could be made possible by an additional format type (e.g. called 0xhex).

Encoding bytes with 0x-prefix is already possible via a custom (un)marshaler. However, doing this at the library level has the benefit that the encoded string does not need extra checks for escape characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal

    Type

    No type

    Projects

    Status

    Post-proposal

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions