The Json.NET serializer has a number of advanced options to alter how JSON is serialized and deserialized.
+
+
IMappingResolver
+
+
The IMappingResolver interface provides a way to globally customize how the JsonSerializer maps JSON properties to .NET object members.
+
Implementing the IMappingResolver interface and then assigning an instance to a JsonSerializer lets you control what object members should be serialized, how they are serialized and what they are called.
+
+
DefaultMappingResolver
+
The DefaultMappingResolver is the default resolver used by the serializer. It provides many avenues of extensibility in the form of virtual methods that can be overriden.
+
+
CamelCaseMappingResolver
+
CamelCaseMappingResolver inherits from DefaultMappingResolver and simply overrides the JSON property name to be written in camelcase.
+
+
+
+
\ No newline at end of file
diff --git a/Src/Doc/DatesInJSON.html b/Src/Doc/DatesInJSON.html
new file mode 100644
index 00000000..fab328c9
--- /dev/null
+++ b/Src/Doc/DatesInJSON.html
@@ -0,0 +1,94 @@
+
+
+
+ Serializing Dates in JSON
+
+
+
+
+
+
+
+ Json.NET - Quick Starts & API Documentation
+ Serializing Dates in JSON
+
+
+
+
DateTimes in JSON are hard.
+
+ The problem comes from the JSON spec itself, there is no literal syntax for dates in JSON. The spec has objects, arrays, strings, integers and floats, but it defines no standard for what a date looks like.
+
The default format used by Json.NET for dates is the same one used by Microsoft: "\/Date(1198908717056)\/". You can read more about it here.
+
+
DateTime JsonConverters
+
With no standard for dates in JSON, the number of possible different formats when interoping with other systems is endless. Fortunately Json.NET has a solution to deal with reading and writing custom dates: JsonConverters. A JsonConverter is used to override how a type is serialized.
Simply pass the JsonConverter you wish to use to the Json.NET serializer.
+
JavaScriptDateTimeConverter
+
The JavaScriptDateTimeConverter class is one of the two DateTime JsonConverters that come with Json.NET. This converter serializes a DateTime as a JavaScript Date object.
+
+
+
+
new Date(1234656000000)
+
+
+
+
+
Technically this is invalid JSON according to the spec but all browsers, and some JSON frameworks including Json.NET, support it.
+
IsoDateTimeConverter
+
IsoDateTimeConverter seralizes a DateTime to an ISO 8601 formatted string.
+
+
+
+
"2009-02-15T00:00:00Z"
+
+
+
+
+
The IsoDateTimeConverter class has a property, DateTimeFormat, to further customize the formatted string.
+
+
One final thing to note is all date values returned by Json.NET are in UTC time.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Src/Doc/ReadingWritingJSON.html b/Src/Doc/ReadingWritingJSON.html
index 64bbbdd4..ad37cc32 100644
--- a/Src/Doc/ReadingWritingJSON.html
+++ b/Src/Doc/ReadingWritingJSON.html
@@ -15,7 +15,7 @@
-
To manually read and write JSON Json.NET provides the JsonWriter classes.
+
To manually read and write JSON Json.NET provides the JsonReader and JsonWriter classes.
JsonTextReader and JsonTextWriter
JsonTextReader and JsonTextWriter are used to read and write JSON text. The JsonTextWriter has a number of settings on it to control how JSON is formatted when it is written. These options include formatting, indention character, indent count and quote character.
@@ -60,7 +60,7 @@
JTokenReader and JTokenWriter
-
JTokenReader and JTokenWriter read and write LINQ to JSON objects. They are located in the Newtonsoft.Json.Linq namespace. These objects allow you to use LINQ to JSON objects with objects that read and write JSON such as the JsonSerializer. For example you can deserialize from a LINQ to JSON object into a regular .NET object and vice versa.
+
JTokenReader and JTokenWriter read and write LINQ to JSON objects. They are located in the Newtonsoft.Json.Linq namespace. These objects allow you to use LINQ to JSON objects with objects that read and write JSON such as the JsonSerializer. For example you can deserialize from a LINQ to JSON object into a regular .NET object and vice versa.
@@ -95,8 +95,14 @@ the member's DefaultValueAttribute. Include or ignore.
Converters
A collection of JsonConverters that will be used during serialization and
deserialization.
+
TypeNameHandling
+
Controls how .NET type names are used when serializing and deserializing JSON. If
+ type names are SDFSDFSDF
Serialization Attributes
There are a number of attributes that can be placed on a class to control how it is serialized.
+
Note that as well as using the built-in Json.NET attributes, Json.NET also looks for the
+ DataContract and
+ DataMember attributes when determining how JSON is to be serialized and deserialized. If both are present the Json.NET serialization attributes take precedence.
@@ -144,17 +150,31 @@ finally any converters passed to the JsonSerializer.
-
IsoDateTimeConverter
-
Converts a DateTime to and from the ISO 8601 date format (e.g. 2008-04-12T12:53Z).
-
-
JavaScriptDateTimeConverter
-
Converts a DateTime to and from a JavaScript date constructor (e.g. new Date(52231943)).
+
DateTime JSON Converters
+
Json.NET comes with a number of JsonConverters for serializing and deserializing DateTimes. Read
+ more about dates and Json.NET here.
XmlNodeConverter
-
Converts an XmlNode to and from JSON. Note that to convert a JSON object it must have only a single property. This is required because properties are converted into nodes and XML can only have one root node.
+
Converts an XmlNode to and from JSON. Note that to convert a JSON object it must have only a single property
+ or you must define a root node name to be inserted when using this converter. This is required because properties are converted into nodes and
+ well formed XML can only have one root node.
-
+
BinaryConverter
+
Converts binary data like a byte array or SqlBinary object to JSON. The binary
+ data is encoded in Base64.
+
+
CustomCreationConverter
+
An abstract JsonConverter for customizing how an object is create during deserialization.
+ Inherit from this class and implement the Create method with your own code to create and return an object.
+ The object will then be populated with JSON values by the serializer.
+
A possible example of using this converter would be to call out to a dependency injection framework to resolve what object should be created