Small repairs on logic
This commit is contained in:
@@ -68,6 +68,20 @@ func (i *Torrent) UnmarshalJSON(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *Torrent) MarshalJSON() ([]byte, error) {
|
||||
type Alias Torrent
|
||||
aux := &struct {
|
||||
Progress float64 `json:"progress"`
|
||||
Added string `json:"added"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(i),
|
||||
Progress: float64(i.Progress), // Convert int to float64 for JSON representation
|
||||
Added: i.Added,
|
||||
}
|
||||
return json.Marshal(aux)
|
||||
}
|
||||
|
||||
type TorrentInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"filename"`
|
||||
|
||||
Reference in New Issue
Block a user