title: Serialize a map using a specific order
body: <p>I have a map that uses string for both key and value. I have an array of keys that specifies the order of the values of the map.</p>
  
  <p>I want to serialize that map to a JSON, but keeping the order defined on the array.</p>
  
  <p>There is a sample code here: <a href="http://play.golang.org/p/A52GTDY6Wx" rel="noreferrer">http://play.golang.org/p/A52GTDY6Wx</a></p>
  
  <p>I want to serialize it as:</p>
  
  <pre><code>{
    "name": "John",
    "age": "20"
  }
  </code></pre>
  
  <p>But if I serialize the map directly, the keys are ordered alphabetically:</p>
  
  <pre><code>{      
    "age": "20",
    "name": "John"
  }
  </code></pre>
  
  <p>I can serialize it as an array of maps, thus keeping the order, however that generates a lot of undesired characters:</p>
  
  <pre><code>[
    {
      "name": "John"
    },
    {
      "age": "20"
    }
  ]
  </code></pre>
  
  <p>In my real code I need to serialize the results of a database query which is specified in a text file, and I need to maintain the column order. I <strong>cannot</strong> use structs because the columns are not known at compile time.</p>
  
  <p>EDIT: I don't need to read the JSON later in the specified order. The generated JSON is meant to be read by people, so I just want it to be as humanly readable as possible.</p>
  
  <p>I could use a custom format but JSON suits me perfectly for this.</p>
  
  <p>Thanks!</p>