Ordering Difference in JSON Marshaled from Map and Struct
<p>When marshaling from a <code>map[string]interface{}</code> and an equivalent <code>struct</code>, the JSON returned are similar but different in the internal order of the keys likewise:</p>

<pre><code>var arg1 = map[string]interface{}{
    "foo": "bar",
    "baz": map[string]interface{}{
        "bee": "boo",
    },
}

type Arg struct {
    Foo string                 `json:"foo"`
    Baz map[string]interface{} `json:"baz"`
}

var arg2 = &amp;Arg{
    Foo: "bar",
    Baz: map[string]interface{}{
        "bee": "boo",
    },
}

func main() {
    result1, _ := json.Marshal(arg1)
    result2, _ := json.Marshal(arg2)

    fmt.Println(reflect.DeepEqual(result1, result2)
    fmt.Println(string(result1))
    fmt.Println(string(result2))

    // false
    // {"baz":{"bee":"boo"},"foo":"bar"}
    // {"foo":"bar","baz":{"bee":"boo"}}

}
</code></pre>

<p>Check the <a href="https://play.golang.org/p/C8KfDWRmsY" rel="noreferrer">playground here</a>. </p>

<p>Although in JSON the order doesn't matter, I'd like to know why are the results ordered differently?</p>