Unmarshal in go must from byte

Run Settings
LanguageGo
Language Version
Run Command
package main import ( "encoding/json" "fmt" ) type Order struct { ID string `json:"id" gorm:"column:id;primaryKey"` Items string `json:"items" gorm:"column:items"` Status uint8 `json:"status" gorm:"column:status"` } func (o Order) ToEntity() { out := []struct { Name string Qty uint8 Price float32 }{} var jsonData = []byte(o.Items) fmt.Println("Items", jsonData) if err := json.Unmarshal(jsonData, &out); err != nil { fmt.Println("Error", err) } fmt.Println("Out", out) } func main() { order1 := Order{ ID: "592494d3-8c42-4881-b04a-1f9a1a63565c", Items: `[{"Name": "ubaidillah", "Qty": 1, "Price":10}]`, Status: 1, } order1.ToEntity() }
Editor Settings
Theme
Key bindings
Full width
Lines