title: Gson serialize/deserialize Map to/from list of KeyValuePairs
body: <p>On the server side I got this API (example) (<strong>I can't modify this.</strong>)</p>
  
  <pre><code>namespace MyNameSpace
  {
      [Serializable][DataContract]
      public class GetMyObject
      {
          [DataMember]
          public Dictionary&lt;int, int&gt; MyDictionary { get; set; }
      }
  }
  </code></pre>
  
  <p>And the server sends this JSON:</p>
  
  <pre><code>{
      "MyDictionary" : 
          [{
              "Key" : 1,
              "Value" : 1
          },
          {
              "Key" : 2,
              "Value" : 2
          },
          {
              "Key" : 3,
              "Value" : 3
          },
          {
              "Key" : 4,
              "Value" : 4
          }]
  }
  </code></pre>
  
  <p>And on the client side, I have to create these classes for correct deserialization:</p>
  
  <pre><code>class GetMyObject {
      @SerializedName("MyDictionary")
      private List&lt;MyDictionaryItem&gt; myDictionary;
  }
  
  class MyDictionaryItem {
      @SerializedName("Key")
      private int key;
  
      @SerializedName("Value")
      private int value;
  }
  </code></pre>
  
  <p><strong>How can I configure GSON to simply use this:</strong> (to serialize and deserialize)</p>
  
  <pre><code>class GetMyObject {
      @SerializedName("MyDictionary")
      private Map&lt;Integer, Integer&gt; myDictionary;
  }
  </code></pre>
  
  <p>It even more intresting with complex key object like:</p>
  
  <pre><code>class ComplexKey {
      @SerializedName("Key1")
      private int key1;
  
      @SerializedName("Key2")
      private String key2;
  }
  
  class GetMyObject {
      @SerializedName("MyDictionary")
      private Map&lt;ComplexKey, Integer&gt; myDictionary;
  }
  </code></pre>