@@ -95,7 +95,7 @@ type XferStatus2 struct {
9595 SeedsPeersRatio float64 `json:"seeds_peers_ratio"`
9696 SeedRank int `json:"seed_rank"`
9797 State string `json:"state"`
98- StopAtRatio bool `json:"stop_at_ratio"`
98+ StopAtRatio Bool `json:"stop_at_ratio"`
9999 StopRatio float64 `json:"stop_ratio"`
100100 TimeAdded float64 `json:"time_added"`
101101 TotalDone float64 `json:"total_done"`
@@ -291,7 +291,7 @@ type XferStatusCompat struct {
291291 SeedsPeersRatio float64 `json:"seeds_peers_ratio"`
292292 SeedRank int `json:"seed_rank"`
293293 State string `json:"state"`
294- StopAtRatio bool `json:"stop_at_ratio"`
294+ StopAtRatio Bool `json:"stop_at_ratio"`
295295 StopRatio float64 `json:"stop_ratio"`
296296 TimeAdded float64 `json:"time_added"`
297297 TotalDone float64 `json:"total_done"`
@@ -366,3 +366,15 @@ type XferStatusCompat struct {
366366 Endpoints []interface {} `json:"endpoints"`
367367 } `json:"trackers"`
368368}
369+
370+ // Bool provides a container and unmarshalling for fields that may be
371+ // boolean or numbrs in the WebUI API.
372+ type Bool bool
373+
374+ // UnmarshalJSON parses fields that may be numbers or booleans.
375+ // https://stackoverflow.com/questions/30856454/how-to-unmarshall-both-0-and-false-as-bool-from-json/56832346#56832346
376+ func (bit * Bool ) UnmarshalJSON (b []byte ) error {
377+ txt := string (b )
378+ * bit = Bool (txt == "1" || txt == "true" )
379+ return nil
380+ }
0 commit comments