在Go中解组要构造的JSON对象-结果为空[重复]

This question already has an answer here:

I'm trying to unmarshal a json object to struct in Go. I tried to stick to this example but I can't get it to work. The result stays empty.

Code:

package main

import (
    "encoding/json"
    "fmt"
)

type MyObject struct {
    id     string
    pubKey string
}

func main() {
    x := `{"id":"abc","pubKey":"QIDAQAB"}`
    fmt.Println("Input: ", x)

    var myObject MyObject
    json.Unmarshal([]byte(x), &myObject)

    fmt.Println("Output: ", myObject)
}

Output:

Input:  {"id":"abc","pubKey":"QIDAQAB"}
Output:  { }

Playground

I found a lot of similar questions but I can't even see a difference between the working example and my non-working code. What am I missing?

</div>

Fields of struct you want to Marshal or Unmarshal must be exported.
Check it out: http://blog.golang.org/json-and-go

The json package only accesses the exported fields of struct types (those that begin with an uppercase letter). Therefore only the the exported fields of a struct will be present in the JSON output.

Working sample: Go playground