-
Notifications
You must be signed in to change notification settings - Fork 138
Open
Description
when schema contains a key with dot in it
a field in UnmarshalJSON function creating with dot (.) in it and getting code errors
like template.hardwareIdReceived := false in below snippet
func (strct *Attrs) UnmarshalJSON(b []byte) error {
template.hardwareIdReceived := false
var jsonMap map[string]json.RawMessage
if err := json.Unmarshal(b, &jsonMap); err != nil {
return err
}
// parse all the defined properties
for k, v := range jsonMap {
switch k {
case "template.hardwareId":
if err := json.Unmarshal([]byte(v), &strct.TemplateHardwareId); err != nil {
return err
}
template.hardwareIdReceived = true
}
}
// check if template.hardwareId (a required property) was received
if !template.hardwareIdReceived {
return errors.New("\"template.hardwareId\" is required but was not present")
}
return nil
}
is there any way to avoid it ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels