Golang Array Of Struct To JSON

The codes below is an example of converting an array of structs into JSON.

package main

import (
"log"
"encoding/json"
)

type Fruit struct {
Name string `json:"name"`
Quantity int `json:"quantity"`
}

func main() {
a := Fruit{Name:"Apple",Quantity:1}
o := Fruit{Name:"Orange",Quantity:2}

var fs []Fruit
fs = append(fs, a)
fs = append(fs, o)
log.Println(fs)

j, _ := json.Marshal(fs)
log.Println(string(j))

j, _ = json.MarshalIndent(fs, "", " ")
log.Println(string(j))
}