This project has moved and is read-only. For the latest updates, please go here.


Writing list to BSON writes as object, should be array, so cannot be read


Serializing a List<Stuff> to JSON and reading it back works fine. But as BSON, there is an error on reading:

Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[BsonBug.Stuff]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

I suspect the root item is being written as an object {...} when it should be an array [...].

Found in version of May 24 2013, also verified in latest 5.0 release 8. The attached code reproduces the error.

file attachments

Closed Dec 19, 2013 at 7:57 PM by JamesNK
Not a bug. Read the documentation