title: How can I create a JSON structure dynamically from Go?
body: <p>As in, serializing JSON.</p>
  
  <p>My current code doesn't work, and I think it must have something to do with the fact that _Map, _String, etc. are not public.</p>
  
  <pre><code>// vim:ft=go:ts=2
  
  package main
  
  import "json"
  import "fmt"
  import vector "container/vector"
  
  func main() {
    groceries := vector.New(0);
    groceries.Push(&amp;json._String{s:"Eggs"});
    groceries.Push(&amp;json._String{s:"Bread"});
    groceries.Push(&amp;json._String{s:"Milk"});
    var tree json.Json = &amp;json._Map{m:map[string]json.Json{
      "hello": &amp;json._String{s:"world"},
      "groceries": &amp;json._Array{a:groceries}
    }};
    fmt.Printf(json.JsonToString(tree));
  }
  </code></pre>