diff --git a/Src/Doc/CustomCreationConverter.html b/Src/Doc/CustomCreationConverter.html
new file mode 100644
index 00000000..cd5c1f0f
--- /dev/null
+++ b/Src/Doc/CustomCreationConverter.html
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+ The CustomCreationConverter is a JsonConverter that provides a way to customize how an object is created
+ during JSON deserialization.
+ Once the object has been created it will then have values populated onto it by the serializer.
+
+
+
+
+
public interface IPerson
+
{
+
string FirstName { get; set; }
+
string LastName { get; set; }
+
DateTime BirthDate { get; set; }
+
}
+
+
public class Employee : IPerson
+
{
+
public string FirstName { get; set; }
+
public string LastName { get; set; }
+
public DateTime BirthDate { get; set; }
+
+
public string Department { get; set; }
+
public string JobTitle { get; set; }
+
}
+
+
public class PersonConverter : CustomCreationConverter<IPerson>
+
{
+
public override IPerson Create(Type objectType)
+
{
+
return new Employee();
+
}
+
}
+
+
+
+
+This is an extremely simple example. A more complicated scenario could involve an object factory or service locator
+ which resolves the object at runtime.
+
+
+
+
+
//[
+
// {
+
// "FirstName": "Maurice",
+
// "LastName": "Moss",
+
// "BirthDate": "\/Date(252291661000)\/",
+
// "Department": "IT",
+
// "JobTitle": "Support"
+
// },
+
// {
+
// "FirstName": "Jen",
+
// "LastName": "Barber",
+
// "BirthDate": "\/Date(258771661000)\/",
+
// "Department": "IT",
+
// "JobTitle": "Manager"
+
// }
+
//]
+
+
List<IPerson> people = JsonConvert.DeserializeObject<List<IPerson>>(json, new PersonConverter());
+
+
IPerson person = people[0];
+
+
Console.WriteLine(person.GetType());
+
// Newtonsoft.Json.Tests.Employee
+
+
Console.WriteLine(person.FirstName);
+
// Maurice
+
+
Employee employee = (Employee)person;
+
+
Console.WriteLine(employee.JobTitle);
+
// Support
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Src/Doc/Introduction.html b/Src/Doc/Introduction.html
index b30b5d03..e7c478c8 100644
--- a/Src/Doc/Introduction.html
+++ b/Src/Doc/Introduction.html
@@ -11,19 +11,18 @@
- The Json.NET library makes working with JavaScript and JSON formatted data in .NET
- simple. Quickly read and write JSON using the JsonReader and JsonWriter or serialize
+ Json.NET makes working with JSON formatted data in .NET
+ simple. Quickly read and write JSON using LINQ to JSON or serialize
your .NET objects with a single method call using the JsonSerializer.
Features
- LINQ to JSON
- - Lightning fast JsonReader and JsonWriter
- The JsonSerializer for quickly converting your .NET objects to JSON and back again
- Json.NET can optionally produce well formatted, indented JSON for debugging or display
- Attributes like JsonIgnore and JsonProperty can be added to a class to customize
how a class is serialized
- - Ability to convert JSON to and from XML
+ - Convert JSON to and from XML
History
@@ -49,9 +48,9 @@
Donate
- Json.NET is a free open source project that is developed in personal time.
+ Json.NET is a free open source project that I have developed in my personal time.
- You can show your appreciation for Json.NET and support future development by donating.
+ You can show your support for Json.NET by donating. I really appreciate your feedback and support.
diff --git a/Src/Doc/LINQtoJSON.html b/Src/Doc/LINQtoJSON.html
index 156b55d4..3eb12253 100644
--- a/Src/Doc/LINQtoJSON.html
+++ b/Src/Doc/LINQtoJSON.html
@@ -149,15 +149,20 @@
Querying JSON
-
The properties methods that are the most useful when querying JSON objects are Children, Values and the property index.
-
Children returns all the children of that object. Values is similar to Children but it allows you to specify a type you would like the values to be converted into. Finally the property index is used to get a specific child, either by index position for JSON arrays or property name for JSON objects.
+
The properties methods that are the most useful when querying JSON objects are
+ the Children
+ method and the property index.
+
Children returns all the children of that object. If it is a JObject it will
+ return a collection of properties to work with and if it is a JArray you will
+ get a collection of the array's values.
+
The property index is used to get a specific child, either by index position for JSON arrays or property name for JSON objects.
var postTitles =
from p in rss["channel"]["item"].Children()
-
select p.Value<string>("title");
+
select (string)p["title"];
foreach (var item in postTitles)
{
@@ -183,6 +188,62 @@
//CodePlex - Count: 1
+
+
+
LINQ to JSON can also be used to manually convert from JSON to a .NET object.
+
+
+
+
public class Shortie
+
{
+
public string Original { get; set; }
+
public string Shortened { get; set; }
+
public string Short { get; set; }
+
public ShortieException Error { get; set; }
+
}
+
+
public class ShortieException
+
{
+
public int Code { get; set; }
+
public string ErrorMessage { get; set; }
+
}
+
+
+
+
Manually serializing and deserializing between .NET objects is most useful when working with JSON that doesn't closely match your .NET objects.
+
+
+
+
+
string jsonText = @"{
+
""short"":{
+
""original"":""http://www.foo.com/"",
+
""short"":""krehqk"",
+
""error"":{
+
""code"":0,
+
""msg"":""No action taken""}
+
}";
+
+
JObject json = JObject.Parse(jsonText);
+
+
Shortie shortie = new Shortie
+
{
+
Original = (string)json["short"]["original"],
+
Short = (string)json["short"]["short"],
+
Error = new ShortieException
+
{
+
Code = (int)json["short"]["error"]["code"],
+
ErrorMessage = (string)json["short"]["error"]["msg"]
+
}
+
};
+
+
Console.WriteLine(shortie.Original);
+
// http://www.foo.com/
+
+
Console.WriteLine(shortie.Error.ErrorMessage);
+
// No action taken
+
+
diff --git a/Src/Doc/ReadingWritingJSON.html b/Src/Doc/ReadingWritingJSON.html
index ad37cc32..6d79db9b 100644
--- a/Src/Doc/ReadingWritingJSON.html
+++ b/Src/Doc/ReadingWritingJSON.html
@@ -73,8 +73,8 @@
JsonSerializer serializer = new JsonSerializer();
Person p = (Person)serializer.Deserialize(new JTokenReader(o), typeof(Person));
-
// John Smith
Console.WriteLine(p.Name);
+
// John Smith
diff --git a/Src/Doc/doc.shfb b/Src/Doc/doc.shfb
index 5508d344..7707d262 100644
--- a/Src/Doc/doc.shfb
+++ b/Src/Doc/doc.shfb
@@ -18,6 +18,7 @@