package main
import (
"encoding/json"
"fmt"
)
type Product struct {
Id string `json:"id"`
Name string `json:"name"`
Price float32 `json:"price"`
Quantity int `json:"quantity"`
Status bool `json:"status"`
}
func main() {
product := Product{"p01", "name 1", 2, 5, true}
str, _ := json.Marshal(product)
fmt.Println(string(str))
}
Output
{"id":"p01","name":"name 1","price":2,"quantity":5,"status":true}