easyjson icon indicating copy to clipboard operation
easyjson copied to clipboard

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

Open klpx opened this issue 5 months ago • 0 comments

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]
}

klpx avatar Oct 03 '24 11:10 klpx