title: How to deserialize a JSON property that can be two different data types using Json.NET
body: <p>I'm using Json.NET for a project I'm working on.
  From an external API, I am receiving JSON with properties that are objects, but when they are empty 'false' is passed.</p>
  
  <p>For example:</p>
  
  <pre><code>data: {
      supplier: {
          id: 15,
          name: 'TheOne'
      }
  }
  </code></pre>
  
  <p>Could also be:</p>
  
  <pre><code>data: {
      supplier: false
  }
  </code></pre>
  
  <p>How should I define the supplier property so that the supplier will be deserialized to a Supplier object or null.</p>
  
  <p>Right now I have:</p>
  
  <pre><code>public class Data {
     [JsonProperty("supplier")]
     public SupplierData Supplier { get; set; }
  }
  public class SupplierData {
      [JsonProperty("id")]
      public int Id { get; set; }
      [JsonProperty("name")]
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>But now when trying to deserialize when supplier has a value of 'false' it fails.
  I would like the Supplier property to be null when the JSON value is 'false'.</p>
  
  <p>I hope someone knows how to do this. Thanks.</p>