title: .Net Deserialize JSON into c# object
body: <p>I'm struggling to convert a json to an c# object.</p>
  
  <p>My json is generated by an other app (in typescript) here is the structure of the object used to generate my json :</p>
  
  <p><a href="https://i.stack.imgur.com/EvEVI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EvEVI.png" alt="enter image description here"></a></p>
  
  <p>With this structure i'm able to create json like: </p>
  
  <pre><code>{
      EQNode: { key: "userid", value: 5}
  }
  </code></pre>
  
  <p>Or more complexe :</p>
  
  <pre><code>{
      AndNode: [
          {
              EQNode: { key: "userid", value: 5 }
          },
          {
              LikeNode: { key: "username", value: "foo" }
          }
      ]
  }
  </code></pre>
  
  <p>Or even more complexe :</p>
  
  <pre><code>{
      AndNode: [
          {
              EQNode: { key: "userid", value: 5 }
          },
          {
              OrNode: [
                  {
                      LikeNode: { key: "username", value: "foo" }
                  },
                  {
                      LikeNode: { key: "email", value: "foo@bar.fr" }
                  },
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I'have managed to parse my json using this model :</p>
  
  <pre><code>public class EQNode
  {
      [JsonProperty("key")]
      public string key { get; set; }
  
      [JsonProperty("value")]
      public int value { get; set; }
  }
  
  public class LikeNode
  {
      [JsonProperty("key")]
      public string key { get; set; }
  
      [JsonProperty("value")]
      public string value { get; set; }
  }
  
  public class GTNode
  {
      [JsonProperty("key")]
      public string key { get; set; }
  
      [JsonProperty("value")]
      public int value { get; set; }
  }
  
  public class LTNode
  {
      [JsonProperty("key")]
      public string key { get; set; }
  
      [JsonProperty("value")]
      public int value { get; set; }
  }
  
  public class OrNode
  {
      [JsonProperty("EQNode")]
      public EQNode EQ { get; set; }
  }
  
  public class AndNode
  {
      [JsonProperty("EQNode")]
      public EQNode EQ { get; set; }
  
      [JsonProperty("LikeNode")]
      public LikeNode LIKE { get; set; }
  
      [JsonProperty("GTNode")]
      public GTNode GT { get; set; }
  
      [JsonProperty("LTNode")]
      public LTNode LT { get; set; }
  
      [JsonProperty("OrNode")]
      public List&lt;OrNode&gt; OR { get; set; }
  
      [JsonProperty("AndNode")]
      public List&lt;OrNode&gt; And { get; set; }
  }
  
  public class RootObject
  {
      [JsonProperty("AndNode")]
      public List&lt;AndNode&gt; And { get; set; }
  
      [JsonProperty("OrNode")]
      public List&lt;OrNode&gt; OR { get; set; }
  
      [JsonProperty("EQNode")]
      public EQNode EQ { get; set; }
  
      [JsonProperty("LikeNode")]
      public LikeNode LIKE { get; set; }
  
      [JsonProperty("GTNode")]
      public GTNode GT { get; set; }
  
      [JsonProperty("LTNode")]
      public LTNode LT { get; set; }
  }
  </code></pre>
  
  <p>But this seems a little "hard coded" to me. Is there a way to have a nice / better model structure for my model ?</p>