Fix unmarshalling of tx_power

This commit is contained in:
Paul Tyng
2021-03-21 21:34:29 -04:00
parent a3d437ef8e
commit 4702e34c81
3 changed files with 3 additions and 1 deletions

View File

@@ -7,7 +7,7 @@
{{ .FieldName }} {{ if .IsArray }}[]{{end}}emptyStringInt `json:"{{ .JSONName }}{{ if .OmitEmpty }}{{ end }}"`{{ end }} {{- end }} {{ .FieldName }} {{ if .IsArray }}[]{{end}}emptyStringInt `json:"{{ .JSONName }}{{ if .OmitEmpty }}{{ end }}"`{{ end }} {{- end }}
{{ define "field-numberOrString" }} {{ define "field-numberOrString" }}
{{- /* this is kind of a hack, probably a better way to do this when looking at the normalized validation */ -}} {{- /* this is kind of a hack, probably a better way to do this when looking at the normalized validation */ -}}
{{- if and (eq .FieldType "string") (or (eq .JSONName "channel") (eq .JSONName "backup_channel")) }} {{- if and (eq .FieldType "string") (or (eq .JSONName "channel") (eq .JSONName "backup_channel") (eq .JSONName "tx_power")) }}
{{ .FieldName }} {{ if .IsArray }}[]{{end}}numberOrString `json:"{{ .JSONName }}{{ if .OmitEmpty }}{{ end }}"`{{ end }} {{- end }} {{ .FieldName }} {{ if .IsArray }}[]{{end}}numberOrString `json:"{{ .JSONName }}{{ if .OmitEmpty }}{{ end }}"`{{ end }} {{- end }}
{{ define "typecast" }} {{ define "typecast" }}
{{- if eq .FieldType "int" }}{{- if .IsArray }} {{- if eq .FieldType "int" }}{{- if .IsArray }}

View File

@@ -121,6 +121,7 @@ func (dst *ChannelPlanRadioTable) UnmarshalJSON(b []byte) error {
aux := &struct { aux := &struct {
BackupChannel numberOrString `json:"backup_channel"` BackupChannel numberOrString `json:"backup_channel"`
Channel numberOrString `json:"channel"` Channel numberOrString `json:"channel"`
TxPower numberOrString `json:"tx_power"`
Width emptyStringInt `json:"width"` Width emptyStringInt `json:"width"`
*Alias *Alias

View File

@@ -302,6 +302,7 @@ func (dst *DeviceRadioTable) UnmarshalJSON(b []byte) error {
Maxsta emptyStringInt `json:"maxsta"` Maxsta emptyStringInt `json:"maxsta"`
MinRssi emptyStringInt `json:"min_rssi"` MinRssi emptyStringInt `json:"min_rssi"`
SensLevel emptyStringInt `json:"sens_level"` SensLevel emptyStringInt `json:"sens_level"`
TxPower numberOrString `json:"tx_power"`
*Alias *Alias
}{ }{