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:
James Stephenson
2021-04-16 09:47:21 -04:00
committed by Paul Tyng
parent 4ab4036985
commit fbed685c37
4 changed files with 48 additions and 26 deletions

View File

@@ -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

View File

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