1

Closed

JArray.Load fails when loading previously serialized arrays when using BSON.

description

So this ended up being an issue only when using the BSON reader / writer.

Here are all my settings and codes.

This same scenario works fine with the JsonText reader / writer.
MockClassC[] testItems = TestResourceFactory.GetMockClassCObjects(25).ToArray();

JsonSerializerSettings defaultSettings = new JsonSerializerSettings()
        {
            NullValueHandling = NullValueHandling.Ignore,
            DateTimeZoneHandling = DateTimeZoneHandling.Utc,
            DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
            DateFormatHandling = DateFormatHandling.IsoDateFormat,
            MissingMemberHandling = MissingMemberHandling.Ignore,
            ContractResolver = new DefaultContractResolver() { IgnoreSerializableInterface = true },
            Formatting = Formatting.None,
            ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
            TypeNameHandling = TypeNameHandling.Objects, //tried adding arrays with no luck.
            TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple
        };

var ms = new MemoryStream();
var bw = new BsonWriter(ms);

JsonSerializer.Create(defaultSettings).Serialize(bw, testItems);

bw.Flush();

ms.Position = 0;
var reader = new BsonReader(ms);

JArray.Load(reader); //error here.

Closed Feb 24, 2013 at 3:32 AM by JamesNK
Look at the properties on BsonReader

comments