This commit is contained in:
lbenedar
2026-03-10 15:50:42 +03:00
parent 1d7beb7de4
commit b4ea20d1d3
2 changed files with 16 additions and 1 deletions

View File

@@ -7,7 +7,7 @@ type Movie struct {
CreatedAt time.Time `json:"-"`
Title string `json:"title"`
Year int32 `json:"year,omitempty"`
Runtime int32 `json:"runtime,omitempty,string"`
Runtime Runtime `json:"runtime,omitempty"`
Genres []string `json:"genres,omitempty"`
Version int32 `json:"version"`
}

15
internal/data/runtime.go Normal file
View File

@@ -0,0 +1,15 @@
package data
import (
"fmt"
"strconv"
)
type Runtime int32
func (r Runtime) MarshalJSON() ([]byte, error) {
jsonValue := fmt.Sprintf("%d mins", r)
quotedJSONValue := strconv.Quote(jsonValue)
return []byte(quotedJSONValue), nil
}