title: Deserialize JSON that might be an integer or a list of strings in C#
body: <p>I am using <code>C#</code> to deserialize a collection of JSON strings. Each string has a property <code>employer_normalized</code> that is supposed to contain a <code>string</code> and <code>List&lt;int&gt;</code> where the values in the <code>List</code> are always positive. In some cases <code>employer_normalized</code> is set to <code>-1</code>, so I want to override these cases with some behavior that sets <code>employer_normalized</code> to <code>null</code>.</p>
  
  <p>Here is my class:</p>
  
  <pre><code>public class EmployerNormalized
  {
    public string company;
    public List&lt;int&gt; code;
  }
  </code></pre>
  
  <p><strong>Good JSON</strong></p>
  
  <pre><code>"employer_normalized": {
          "company": "self",
          "code": [
            "4581 ",
            "6732 ",
            "9121",
            "9999 ",
            "5947 ",
            "8322 ",
            "8351 ",
            "7335 ",
            "9999 ",
            "4225 ",
            "8399 "
          ]
        }
  </code></pre>
  
  <p><strong>Bad JSON</strong></p>
  
  <pre><code>"employer_normalized": -1
  </code></pre>
  
  <p>I am currently using <code>Json.NET</code> to do my JSON parsing. What is an elegant solution to solving this problem? Is it best to just set the <code>employer_normalized</code> value to <code>null</code> if it is <code>-1</code>? If so, how can I do this?</p>