Closed xocasdashdash closed 5 years ago
HI, sorry for the time it took to answer. The generator is limited at the moment and we're working on a much thorough implementation.
For now, you can implement it yourself this way:
type MyVeryOwnMap map[string]string
type MyStruct struct {
Properties MyVeryOwnMap gojay:"properties"
}
func (m *MyStruct) MarshalJSONObject(enc *gojay.Encoder) {
enc.ObjectKey("properties", m.Properties)
}
func (m *MyStruct) IsNil() bool {
return m == nil
}
func (m MyVeryOwnMap) MarshalJSONObject(enc *gojay.Encoder) {
for k, v := range m {
enc.StringKey(k, v)
}
}
func (m MyVeryOwnMap) IsNil() bool {
return m == nil
}
Thanks
Sorry I closed the wrong dupe: I'm trying to decode this structure
type MyVeryOwnMap map[string]string
type MyStruct struct { Properties MyVeryOwnMap
gojay:"properties"
} In the end the gojay generator is trying to generate this code:But that method is nowhere, How can I get gojay to encode (and decode) a map[string]string
Is the generator the right way of using this library? Thanks!