JSON.net 1.3.1 custom collection

Nov 22, 2007 at 2:08 AM
hello James

I read the release note and notice that you said "New feature - JsonSerializer now supports deserializing read only collections and has better support for custom collections. "

But I actually when I used Json.net to serialize my custom collection, the result is not what I expected.
My custom collection as following:
==================
namespace xyz{
Serializable
public class DocumentInfoCollection : CollectionBase
{
private int _totalCount;
private int _pageIndex;
private long _executionTime;

public DocumentInfoCollection()
{
}

public DocumentInfo thisint index
{
get { return (DocumentInfo)this.Listindex; }
}

public int TotalCount
{
get { return this._totalCount; }
set { this._totalCount = value; }
}

public int PageIndex
{
get { return this._pageIndex; }
set { this._pageIndex = value; }
}

public long ExecutionTime
{
get { return this._executionTime; }
set { this._executionTime = value; }
}

public void Add(DocumentInfo documentInfo)
{
this.List.Add(documentInfo);
}

public void Remove(DocumentInfo documentInfo)
{
this.List.Remove(documentInfo);
}
}
}

=========================================
I check the json.net code and found that everytime that JsonSerializer.cs
at line 512 516 520
because my collection inherits CollecionBase and CollectionBase implements IList, ICollection
so JsonSerializer will treat my collection as IList and serialize to JSONarray. Actually I want it to be serialized like following json string.
*****************************
{
TotalCount:123,
ExecutionTime:2,
PageIndex:1,
Elements:
[
{
DocumentId:1,
DocumentTitle:"abc"
},
{
DocumentId:2,
DocumentTitle:"def"
},....
]
}
*****************************
Could it be possible or it makes sense?
Thanks :D