You need to use DataContractJsonSerializer which is in the System.Runtime.Serialization.Json namespace. Mark your class with the [DataContract] attribute, collection classes with the [CollectionDataContract] attribute and the properties with the [DataMember] attribute.
[CollectionDataContract]
public class People : List<Person>
{
}
[DataContract]
public class Person
{
public Person() { }
[DataMember]
public int Id{ get; set; }
[DataMember]
public string Name { get; set; }
}
Here is a helper class to serialize (To) and deserialize (From)
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
public class jsonHelper
{
public static string To<T>(T obj)
{
string retVal = null;
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType());
using (MemoryStream ms = new MemoryStream())
{
serializer.WriteObject(ms, obj);
retVal = Encoding.Default.GetString(ms.ToArray());
}
return retVal;
}
public static T From<T>(string json)
{
T obj = Activator.CreateInstance<T>();
using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json)))
{
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType());
obj = (T)serializer.ReadObject(ms);
}
return obj;
}
}
So take your json above and send it to the From method in the jsonHelper class above
People peeps = jsonHelper.From<People>(input);