Serialize/deserialize IPagedList<T> using JSON.NET
<p>I have the following use case, I want to serialize/deserialize my IPagedList of T using JSON.net (Newtonsoft.Json). This seems not to be working. It does not serialize everything, only the items (or with my own ContractResolver, the object with empty properties). I am using the X.PagedList nuget.</p>

<p>A test case:</p>

<pre><code>var list = new List&lt;int&gt;(Enumerable.Range(1, 1000));
var paged = list.AsQueryable().ToPagedList(3, 10);


var json = JsonConvert.SerializeObject(paged); (output: [21,22,23,24,25,26,27,28,29,30])
var obj = JsonConvert.DeserializeObject&lt;PagedList&lt;int&gt;&gt;(json);
</code></pre>

<p>When I extend the DefaultContractResolver and override the CreateContract method, it deserializes to the IPagedList object but with no properties filled, and also no items.. I tried to override the CreateProperties but that didn't work as I expected.</p>

<pre><code>protected override JsonContract CreateContract(Type objectType)
{
    if (typeof(IPagedList).IsAssignableFrom(objectType))
    {
        return CreateObjectContract(objectType);
    }
   return base.CreateContract(objectType);
}
</code></pre>

<p>So how can I successfully serialize/deserialize this class?</p>