-JSON Schema fixes

-Fixed static values being included with fields serialization
-Examples! (work in progress)
This commit is contained in:
James Newton-King
2013-01-23 21:39:54 +13:00
parent 9187d8a6b3
commit 68eacc480b
87 changed files with 3519 additions and 53 deletions
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Bson;
namespace Newtonsoft.Json.Tests.Documentation.Examples
{
public class DeserializeFromBsonCollection
{
public class Event
{
public string Name { get; set; }
public DateTime StartDate { get; set; }
}
public void Example()
{
byte[] data = Convert.FromBase64String("awAAAAMwADAAAAACTmFtZQAOAAAATW92aWUgcHJlbWllcgAJU3RhcnREYXRlAMDgKWE8AQAAAAMxADAAAAACTmFtZQAOAAAATW92aWUgcHJlbWllcgAJU3RhcnREYXRlAMDgKWE8AQAAAAA=");
MemoryStream ms = new MemoryStream(data);
using (BsonReader reader = new BsonReader(ms))
{
reader.ReadRootValueAsArray = true;
JsonSerializer serializer = new JsonSerializer();
IList<Event> events = serializer.Deserialize<IList<Event>>(reader);
Console.WriteLine(events.Count);
// 2
}
}
}
}