Fixing unmarshalling of numberOrString
New unmarshalling rules for fields which could be numeric or string values were not properly typecasted upon being deserialized. Cleaned up the api template file and moved custom unmarshalling type logic into go code out of the template.
This commit is contained in:
committed by
Paul Tyng
parent
4ab4036985
commit
fbed685c37
@@ -133,6 +133,9 @@ func (dst *ChannelPlanRadioTable) UnmarshalJSON(b []byte) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||
}
|
||||
dst.BackupChannel = string(aux.BackupChannel)
|
||||
dst.Channel = string(aux.Channel)
|
||||
dst.TxPower = string(aux.TxPower)
|
||||
dst.Width = int(aux.Width)
|
||||
|
||||
return nil
|
||||
|
||||
@@ -315,9 +315,12 @@ func (dst *DeviceRadioTable) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
dst.AntennaGain = int(aux.AntennaGain)
|
||||
dst.AntennaID = int(aux.AntennaID)
|
||||
dst.BackupChannel = string(aux.BackupChannel)
|
||||
dst.Channel = string(aux.Channel)
|
||||
dst.Maxsta = int(aux.Maxsta)
|
||||
dst.MinRssi = int(aux.MinRssi)
|
||||
dst.SensLevel = int(aux.SensLevel)
|
||||
dst.TxPower = string(aux.TxPower)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user