package main
import (
"encoding/json"
"fmt"
)
func main() {
product := map[string]interface{}{
"id": 1,
"name": "Name 1",
"price": 5.6,
"status": true,
}
jsonStr, err := json.Marshal(product)
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Println(string(jsonStr))
}
}
Output
{"id":1,"name":"Name 1","price":5.6,"status":true}