-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,45 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Linq;
namespace Newtonsoft.Json.Tests.Documentation.Examples
{
public class SerializeToBson
{
public class Event
{
public string Name { get; set; }
public DateTime StartDate { get; set; }
}
public void Example()
{
Event e = new Event
{
Name = "Movie premier",
StartDate = new DateTime(2013, 1, 22, 20, 30, 0)
};
IList<Event> es = new List<Event>
{
e, e
};
MemoryStream ms = new MemoryStream();
using (BsonWriter writer = new BsonWriter(ms))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(writer, es);
}
string data = Convert.ToBase64String(ms.ToArray());
Console.WriteLine(data);
// MAAAAAJOYW1lAA4AAABNb3ZpZSBwcmVtaWVyAAlTdGFydERhdGUAwOApYTwBAAAA
}
}
}