Skip to content

String interning for map[string] keys (feature proposal) #403

@klpx

Description

@klpx

Hi! It is great, that easyjson has an option to intern strings:

type Foo struct {
  UUID  string `json:"uuid"`         // will not be interned during unmarshaling
  State string `json:"state,intern"` // will be interned during unmarshaling
}

But the another common target for interning might be actually a string key in arbitrary map[string], because sometimes keys are same, but there is also just a few of them.

type User struct {
  ID  string `json:"id"`
  Settings map[string]any `json:"settings,intern"` // applies to keys of top-level map and all nested map[string]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions