Adjusting the structure when unmarshalling json in go
<p>Unmarshalling JSON (that I do not control) like this:</p>

<pre><code>{
    "states": {
        "state": [
            { ...}
        ]
    }
}
</code></pre>

<p>into a struct like:</p>

<pre><code>type Device struct {
    States    struct{ State []State }
}
var dev Device
</code></pre>

<p>I get an ugly syntax to access a state:</p>

<pre><code>dev.States.State[0]
</code></pre>

<p>I would like to be able to transform the object so I can do</p>

<pre><code>dev.States[0]
</code></pre>

<p>Can this be done with tags (omitted in the above example because not needed), or with another method, or do I have to first unmarshal to a struct like the above then manually remap to a struct as I want it?</p>