title: Deserializing a JSON object using gson when keys are now known in advance
body: <p>I am trying to parse a JSON object which consists of an Array of Customer objects.   Each customer object contains a number of key/value pairs:</p>
  
  <pre><code>{
     "Customers": 
     [
       {
          "customer.name": "acme corp",
          "some_key": "value",
          "other_key": "other_value",
          "another_key": "another value"
       },
       {
          "customer.name": "bluechip",
          "different_key": "value",
          "foo_key": "other_value",
          "baa": "another value"
       }
     ]
  }
  </code></pre>
  
  <p>The complication is that the keys are not known to me in advance.  A second complication is that the keys contain periods (.) that mean that even when I have tried to map them to a field, it fails.</p>
  
  <p>I have been trying to map these to a Customers class:</p>
  
  <pre><code>Customers data = new Gson().fromJson(responseStr, Customers.class);
  </code></pre>
  
  <p>which looks like this:</p>
  
  <pre><code>public class Customers {
  
      public List&lt;Customer&gt; Customers;
  
      static public class Customer {
  
          public List&lt;KeyValuePair&gt; properties;
          public class KeyValuePair {
              String key;
              Object value;
          }     
      }
  }
  </code></pre>
  
  <p>My problem is that in when I load this class from the JSON, my Customers list populates, but their properties are null.  How can I make GSON deal with the fact that I don't know the key names?</p>
  
  <p>I have tried various other approaches including putting a HashMap in the Customer class, in place of the KeyValuePair class.</p>