title: Custom deserialization of property in json.net
body: <p>I query an API that has a strange serialization pattern. Some properties may either be null (not existing) or an array of objects (default) or even just an object. It depends on how many items are in the list. </p>
  
  <pre><code>{
     persons: null
  }
  </code></pre>
  
  <p>or </p>
  
  <pre><code>{
     persons: { name: "lastname1, firstname1" }
  }
  </code></pre>
  
  <p>or </p>
  
  <pre><code>{
      persons: [{ name: "lastname1, firstname1" }, { name: "lastname2, firstname2" }]
  }
  </code></pre>
  
  <p>Now I want to deserialize this using json.net. But I don't know how to define my model. When I define persons property as List&lt;Person&gt; case 1 and 3 deserialize fine, but case 2 fails; when I define it as a Person, case 1 and 2 deserialize fine. The best would be, when I could define it as a list of persons and write something that instructs json.net to deserialize it correctly. Now json.net has some concepts to intercept serialization and deserialization. What's the best approach to solve this?</p>