title: JSON Newtonsoft C# Good Practice for Serialize/ Deserialize Lists of Objects
body: <p>I've readed others posts here about this question </p>
  
  <p><a href="https://stackoverflow.com/questions/23904752/serializing-a-list-of-object-using-json-net">Serializing a list of Object using Json.NET</a></p>
  
  <p><a href="https://stackoverflow.com/questions/9110724/serializing-a-list-to-json">Serializing a list to JSON</a></p>
  
  <p><a href="https://stackoverflow.com/questions/19811301/merge-two-objects-during-serialization-using-json-net">Merge two objects during serialization using json.net?</a></p>
  
  <p>All very useful. Certain, I can serialize in one json two lists, but I cant deserialize it.</p>
  
  <p>I´m working with Json Newtonsoft, C#, MVC5, framework 4.5. This is the scenario:</p>
  
  <p><strong>C# CODE</strong></p>
  
  <pre><code>public class User
  {
      public int id { get; set; }
      public string name { get; set; }
  }
  
  public class Request
  {
      public int id { get; set; }
      public int idUSer{ get; set; } 
  }
  
  List&lt;User&gt; UserList = new List&lt;User&gt;();          
  List&lt;Request&gt; RequestList = new List&lt;Request&gt;();
  string json=  JsonConvert.SerializeObject(new { UserList, RequestList });
  </code></pre>
  
  <p><strong>JSON RESULT</strong></p>
  
  <pre><code>{
  "UserList":[
    {
       "id":1,
       "name":"User 1"
    },
    {
       "id":2,
       "name":"User 2"
    },
    {
       "id":3,
       "name":"User 3"
    }
   ],
  "RequestList":[
    {
       "id":1,
       "idUSer":1
    },
    {
       "id":2,
       "idUSer":1
    },
    {
       "id":3,
       "idUSer":1
    },
    {
       "id":4,
       "idUSer":2
    }
    ]
    }
  </code></pre>
  
  <p><strong>C# DESERIALIZE</strong></p>
  
  <p>I dont Know how configure the settings of Json.Deserialize&lt; ?, Settings>(json) for indicate what types of objects are being deserialized.</p>
  
  <p><strong>Change of approach</strong></p>
  
  <p>So that,  change of approach, I've created a new class "Cover" in order to put the lists together and serialize one object</p>
  
  <pre><code> public class Cover
   {
      private List&lt;User&gt; user = new List&lt;User&gt;();
      private List&lt;Request&gt; request = new List&lt;Request&gt;();
  
      public List&lt;User&gt; User 
      { 
          get { return user;}
          set { User = value;}        
      }      
  
      public List&lt;Request&gt; Request
      {
          get {return request;}
          set {Request = value;}
      }
    }
  </code></pre>
  
  <p><strong>SERIALIZE</strong> </p>
  
  <pre><code>string json = JsonConvert.SerializeObject(cover);
  </code></pre>
  
  <p><strong>JSON</strong> The json result is the same. </p>
  
  <p><strong>DESERIALIZE</strong>     </p>
  
  <pre><code> Cover  result = JsonConvert.DeserializeObject&lt;Cover&gt;(json, new 
   JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto });
  </code></pre>
  
  <p>It's work fine. My situation is resolved but I have doubts about concepts, in my mind something is not clear: </p>
  
  <p><strong>MY QUESTIONS ARE:</strong></p>
  
  <p>For the first aproach: </p>
  
  <p>Do you think that there is a way to deserialize a json with different lists of objects? Is not a good practice?</p>
  
  <p>Second aproach: Why jsons are equals for first situation?</p>