编码期间未考虑JSON字段标签问题

I have the following Go code

    type Version struct {
        Name string `json: "name"`
        Project   string `json: "project"`
        ProjectId int    `json: "projectId"`
    }

    b := new(bytes.Buffer)
    if err := json.NewEncoder(b).Encode(&Version{"foo", "bar", 42}); err != nil {
        log.Fatal(err)
        return false
    }

    fmt.Printf("JSON %v", b)

The output is:

{"Name":"foo","Project":"bar","ProjectId": 42}

instead of:

{"name":"foo","project":"bar","projectId": 42}

Any thoughts why?

Thanks

Your struct tags aren't proper so the parser isn't working as expected

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "log"
)

type Version struct {
    Name      string `json:"name"`
    Project   string `json:"project"`
    ProjectId int    `json:"project_id"`
}

func main() {
    b := new(bytes.Buffer)
    if err := json.NewEncoder(b).Encode(&Version{"foo", "bar", 42}); err != nil {
        log.Fatal(err)
    }

    fmt.Printf("JSON %v", b)
}

works as expected