Golang: json Unmarshal fails to unpack simple example : <p>I cannot get my head around this problem. I have a simple struct, and another struct that uses it twice:</p>

<pre><code>type Range struct {
    Position int `json:"position"`
    Length   int `json:"length"`
}

type TwoRanges struct {
    From Range `json:"from"`
    To   Range `json:"to"`
}
</code></pre>

<p>and the following json sample in file "ranges.json":</p>

<pre><code>{
"from:": {
    "position": 348,
    "length": 15
},
"to": {
    "position": 737,
    "length" : 10
}
}
</code></pre>

<p>I try unmarshalling the sample in the following code:</p>

<pre><code>func main() {
    buffer, err := ioutil.ReadFile("ranges.json")
    if err != nil {
        log.Fatal(err)
    }
    var sample TwoRanges
    if err = json.Unmarshal(buffer, &amp;sample); err != nil {
        log.Fatal(err)
    }

    fmt.Printf("%v\n", sample)
}
</code></pre>

<p>The output is</p>

<pre><code>{{0 0} {737 10}}
</code></pre>

<p>Somehow, only the half of the struct is unpacked.</p>

<ol>
<li>Is it a bug, or am I doing something wrong?</li>
<li>Is there a "verbose mode" for the encoding/json package which would tell me what went wrong with the unmarshaller? It's not the first time that I've had mysterious problems with that package. </li>
</ol>
