title: Gson custom deseralizer for one variable in an object
body: <p>My probelm example:</p>
  
  <p>We have an object type of Apple. Apple has some member variables:</p>
  
  <pre><code>String appleName; // The apples name
  String appleBrand; // The apples brand
  List&lt;Seed&gt; seeds; // A list of seeds the apple has
  </code></pre>
  
  <p>And the seed object looks as follows.</p>
  
  <pre><code>String seedName; // The seeds name
  long seedSize; // The size of the seed
  </code></pre>
  
  <p>Now When I get an apple object, an apple could have more than one seed, or it could have one seed, or maybe no seeds!</p>
  
  <p>Example JSON apple with one seed:</p>
  
  <pre><code>{
  "apple" : {
     "apple_name" : "Jimmy", 
     "apple_brand" : "Awesome Brand" , 
     "seeds" : {"seed_name":"Loopy" , "seed_size":"14" }
    }
  }
  </code></pre>
  
  <p>Example JSON apple with two seeds:</p>
  
  <pre><code>{
  "apple" : {
     "apple_name" : "Jimmy" , 
     "apple_brand" : "Awesome Brand" , 
     "seeds" : [ 
        { 
           "seed_name" : "Loopy",
           "seed_size" : "14"
        },
        {
           "seed_name" : "Quake",
           "seed_size" : "26"
        } 
    ]}
  }
  </code></pre>
  
  <p>Now the issue here is the first example is a JSONObject for seeds, the second example is a JSONArray for seeds.  Now I know its inconsistent JSON and the easiest way to fix it would be fix the JSON itself, but unfortunately I'm getting the JSON from some one else, so I cant fix it. What would be the easiest way to fix this issue?</p>