<p>I have a problem parsing the metadata in ClusterRole object from Json in Go.</p>
<p>I made this example:</p>
<pre class="lang-golang prettyprint-override"><code>package main

import (
    &quot;encoding/json&quot;
    &quot;fmt&quot;

    &quot;k8s.io/kubernetes/pkg/apis/rbac&quot;
)

func main() {
    clusterDemo := rbac.ClusterRole{}

    clusterRolesRaw := `{
        &quot;apiVersion&quot;: &quot;rbac.authorization.k8s.io/v1&quot;,
        &quot;kind&quot;: &quot;ClusterRole&quot;,
        &quot;metadata&quot;: {
            &quot;creationTimestamp&quot;: &quot;2021-01-21T08:07:13Z&quot;,
            &quot;managedFields&quot;: [],
            &quot;name&quot;: &quot;kubeadm:get-nodes&quot;,
            &quot;resourceVersion&quot;: &quot;220&quot;,
            &quot;uid&quot;: &quot;c78a8b10-cd20-4b64-8e4d-4f7f758c7b65&quot;
        },
        &quot;rules&quot;: []
    }`
    err := json.Unmarshal([]byte(clusterRolesRaw), &amp;clusterDemo)
    if err != nil {
        fmt.Printf(&quot;unmarshal file: %v&quot;, err)
    }
    fmt.Printf(&quot;Name: %s\n&quot;, clusterDemo.Name)
    fmt.Printf(&quot;Kind: %s\n&quot;, clusterDemo.Kind)
}

</code></pre>
<p>Run it with</p>
<pre><code># go get -v ./... 
# go run &lt;filename&gt;
Name: 
Kind: ClusterRole
</code></pre>
<p>As you can see, the Kind field is parsed, but the Name field (part of the metadata) is not.</p>
<p>My question is why? It looks like the nested structure is not parsed.</p>
<p>Any help is appreciated, I think I am missing something</p>

<p>Change your import from <code>&quot;k8s.io/kubernetes/pkg/apis/rbac&quot;</code> to <code>rbac &quot;k8s.io/api/rbac/v1&quot;</code>.</p>
<p>It should work.</p>
