From fd7970a3c37123e37d3e75b52d4b67bd5a19a13b Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sat, 26 Jan 2013 14:46:05 +1300 Subject: [PATCH] -Examples! --- Build/build.ps1 | 2 +- Doc/Examples/Examples.aml | 41 +++++++++++ Doc/Examples/Serializer.aml | 70 +++++++++++++++++++ .../Serializer/CustomContractResolver.aml | 16 +++++ .../Serializer/CustomJsonConverter.aml | 16 +++++ Doc/Examples/Serializer/CustomTraceWriter.aml | 21 ++++++ .../Serializer/DataContractAndDataMember.aml | 19 +++++ .../DefaultValueAttributeIgnore.aml | 17 +++++ .../Serializer/DefaultValueHandlingIgnore.aml | 16 +++++ .../Serializer/DeserializeAnonymousType.aml | 14 ++++ .../Serializer/DeserializeCollection.aml | 14 ++++ .../DeserializeConstructorHandling.aml | 16 +++++ .../DeserializeCustomCreationConverter.aml | 16 +++++ .../Serializer/DeserializeDataSet.aml | 14 ++++ .../Serializer/DeserializeDictionary.aml | 14 ++++ .../DeserializeMissingMemberHandling.aml | 16 +++++ Doc/Examples/Serializer/DeserializeObject.aml | 15 ++++ .../DeserializeObjectCreationHandling.aml | 16 +++++ .../DeserializeWithJsonSerializerFromFile.aml | 15 ++++ .../Serializer/ErrorHandlingAttribute.aml | 15 ++++ .../Serializer/ErrorHandlingEvent.aml | 15 ++++ .../JsonConverterAttributeClass.aml | 18 +++++ .../JsonConverterAttributeProperty.aml | 18 +++++ .../Serializer/JsonObjectAttributeOptIn.aml | 19 +++++ ...JsonObjectAttributeOverrideIEnumerable.aml | 17 +++++ .../JsonPropertyItemLevelSetting.aml | 18 +++++ Doc/Examples/Serializer/JsonPropertyName.aml | 16 +++++ Doc/Examples/Serializer/JsonPropertyOrder.aml | 16 +++++ .../JsonPropertyPropertyLevelSetting.aml | 16 +++++ .../Serializer/JsonPropertyRequired.aml | 17 +++++ Doc/Examples/Serializer/MaxDepth.aml | 15 ++++ .../Serializer/NullValueHandlingIgnore.aml | 16 +++++ Doc/Examples/Serializer/PopulateObject.aml | 15 ++++ .../PreserveReferencesHandlingObject.aml | 16 +++++ .../Serializer/PropertyJsonIgnore.aml | 16 +++++ .../ReferenceLoopHandlingIgnore.aml | 16 +++++ .../SerializationCallbackAttributes.aml | 20 ++++++ .../Serializer/SerializeCollection.aml | 14 ++++ .../SerializeConditionalProperty.aml | 15 ++++ .../Serializer/SerializeContractResolver.aml | 16 +++++ Doc/Examples/Serializer/SerializeDataSet.aml | 14 ++++ .../SerializeDateFormatHandling.aml | 15 ++++ .../SerializeDateTimeZoneHandling.aml | 16 +++++ .../Serializer/SerializeDictionary.aml | 14 ++++ Doc/Examples/Serializer/SerializeObject.aml | 15 ++++ Doc/Examples/Serializer/SerializeRawJson.aml | 16 +++++ .../SerializeSerializationBinder.aml | 16 +++++ .../Serializer/SerializeTypeNameHandling.aml | 16 +++++ .../Serializer/SerializeUnindentedJson.aml | 15 ++++ .../SerializeWithJsonConverters.aml | 15 ++++ .../SerializeWithJsonSerializerToFile.aml | 15 ++++ Doc/Examples/Serializer/TraceWriter.aml | 16 +++++ Doc/doc.content | 57 ++++++++++++++- Doc/doc.shfbproj | 55 +++++++++++++++ .../Examples/Linq/DeserializeWithLinq.cs | 14 ++-- .../Documentation/Examples/Linq/ModifyJson.cs | 12 ++-- .../Examples/Linq/ParseJsonAny.cs | 2 +- .../Examples/Linq/QueryJsonDynamic.cs | 14 ++-- .../Examples/Linq/ToObjectComplex.cs | 6 +- .../Examples/Schema/RefJsonSchemaResolver.cs | 30 ++++---- .../Serializer/CustomContractResolver.cs | 4 ++ .../Serializer/CustomJsonConverter.cs | 4 ++ .../Examples/Serializer/CustomTraceWriter.cs | 4 ++ .../Serializer/DataContractAndDataMember.cs | 4 ++ .../Serializer/DefaultValueAttributeIgnore.cs | 4 ++ .../Serializer/DefaultValueHandlingIgnore.cs | 4 ++ .../Serializer/DeserializeAnonymousType.cs | 4 +- .../Serializer/DeserializeCollection.cs | 6 +- .../DeserializeConstructorHandling.cs | 6 +- .../DeserializeCustomCreationConverter.cs | 14 ++-- .../Examples/Serializer/DeserializeDataSet.cs | 12 ++-- .../Serializer/DeserializeDictionary.cs | 6 +- .../DeserializeMissingMemberHandling.cs | 13 ++-- .../Examples/Serializer/DeserializeObject.cs | 16 +++-- .../DeserializeObjectCreationHandling.cs | 14 ++-- .../DeserializeWithJsonSerializerFromFile.cs | 4 ++ .../Serializer/ErrorHandlingAttribute.cs | 4 ++ .../Examples/Serializer/ErrorHandlingEvent.cs | 2 + .../Serializer/JsonConverterAttributeClass.cs | 4 ++ .../JsonConverterAttributeProperty.cs | 4 ++ .../Serializer/JsonObjectAttributeOptIn.cs | 4 ++ .../JsonObjectAttributeOverrideIEnumerable.cs | 4 ++ .../JsonPropertyItemLevelSetting.cs | 4 ++ .../Examples/Serializer/JsonPropertyName.cs | 4 ++ .../Examples/Serializer/JsonPropertyOrder.cs | 6 +- .../JsonPropertyPropertyLevelSetting.cs | 4 ++ .../Serializer/JsonPropertyRequired.cs | 8 ++- .../Examples/Serializer/MaxDepth.cs | 8 ++- .../Serializer/NullValueHandlingIgnore.cs | 4 ++ .../Examples/Serializer/PopulateObject.cs | 10 ++- ...cs => PreserveReferencesHandlingObject.cs} | 6 +- .../Examples/Serializer/PropertyJsonIgnore.cs | 4 ++ .../Serializer/ReferenceLoopHandlingIgnore.cs | 4 ++ .../SerializationCallbackAttributes.cs | 4 ++ .../Serializer/SerializeCollection.cs | 2 + .../SerializeConditionalProperty.cs | 6 ++ .../Serializer/SerializeContractResolver.cs | 4 ++ .../Examples/Serializer/SerializeDataSet.cs | 2 + .../Serializer/SerializeDateFormatHandling.cs | 2 + .../SerializeDateTimeZoneHandling.cs | 6 +- .../Serializer/SerializeDictionary.cs | 2 + .../Examples/Serializer/SerializeObject.cs | 4 ++ .../Examples/Serializer/SerializeRawJson.cs | 4 ++ .../SerializeSerializationBinder.cs | 4 ++ .../Serializer/SerializeTypeNameHandling.cs | 4 ++ .../Serializer/SerializeUnindentedJson.cs | 4 ++ .../Serializer/SerializeWithJsonConverters.cs | 2 + .../SerializeWithJsonSerializerToFile.cs | 4 ++ .../Examples/Serializer/TraceWriter.cs | 10 ++- .../Examples/Xml/ConvertJsonToXml.cs | 22 +++--- .../Newtonsoft.Json.Tests.csproj | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- 113 files changed, 1279 insertions(+), 101 deletions(-) create mode 100644 Doc/Examples/Examples.aml create mode 100644 Doc/Examples/Serializer.aml create mode 100644 Doc/Examples/Serializer/CustomContractResolver.aml create mode 100644 Doc/Examples/Serializer/CustomJsonConverter.aml create mode 100644 Doc/Examples/Serializer/CustomTraceWriter.aml create mode 100644 Doc/Examples/Serializer/DataContractAndDataMember.aml create mode 100644 Doc/Examples/Serializer/DefaultValueAttributeIgnore.aml create mode 100644 Doc/Examples/Serializer/DefaultValueHandlingIgnore.aml create mode 100644 Doc/Examples/Serializer/DeserializeAnonymousType.aml create mode 100644 Doc/Examples/Serializer/DeserializeCollection.aml create mode 100644 Doc/Examples/Serializer/DeserializeConstructorHandling.aml create mode 100644 Doc/Examples/Serializer/DeserializeCustomCreationConverter.aml create mode 100644 Doc/Examples/Serializer/DeserializeDataSet.aml create mode 100644 Doc/Examples/Serializer/DeserializeDictionary.aml create mode 100644 Doc/Examples/Serializer/DeserializeMissingMemberHandling.aml create mode 100644 Doc/Examples/Serializer/DeserializeObject.aml create mode 100644 Doc/Examples/Serializer/DeserializeObjectCreationHandling.aml create mode 100644 Doc/Examples/Serializer/DeserializeWithJsonSerializerFromFile.aml create mode 100644 Doc/Examples/Serializer/ErrorHandlingAttribute.aml create mode 100644 Doc/Examples/Serializer/ErrorHandlingEvent.aml create mode 100644 Doc/Examples/Serializer/JsonConverterAttributeClass.aml create mode 100644 Doc/Examples/Serializer/JsonConverterAttributeProperty.aml create mode 100644 Doc/Examples/Serializer/JsonObjectAttributeOptIn.aml create mode 100644 Doc/Examples/Serializer/JsonObjectAttributeOverrideIEnumerable.aml create mode 100644 Doc/Examples/Serializer/JsonPropertyItemLevelSetting.aml create mode 100644 Doc/Examples/Serializer/JsonPropertyName.aml create mode 100644 Doc/Examples/Serializer/JsonPropertyOrder.aml create mode 100644 Doc/Examples/Serializer/JsonPropertyPropertyLevelSetting.aml create mode 100644 Doc/Examples/Serializer/JsonPropertyRequired.aml create mode 100644 Doc/Examples/Serializer/MaxDepth.aml create mode 100644 Doc/Examples/Serializer/NullValueHandlingIgnore.aml create mode 100644 Doc/Examples/Serializer/PopulateObject.aml create mode 100644 Doc/Examples/Serializer/PreserveReferencesHandlingObject.aml create mode 100644 Doc/Examples/Serializer/PropertyJsonIgnore.aml create mode 100644 Doc/Examples/Serializer/ReferenceLoopHandlingIgnore.aml create mode 100644 Doc/Examples/Serializer/SerializationCallbackAttributes.aml create mode 100644 Doc/Examples/Serializer/SerializeCollection.aml create mode 100644 Doc/Examples/Serializer/SerializeConditionalProperty.aml create mode 100644 Doc/Examples/Serializer/SerializeContractResolver.aml create mode 100644 Doc/Examples/Serializer/SerializeDataSet.aml create mode 100644 Doc/Examples/Serializer/SerializeDateFormatHandling.aml create mode 100644 Doc/Examples/Serializer/SerializeDateTimeZoneHandling.aml create mode 100644 Doc/Examples/Serializer/SerializeDictionary.aml create mode 100644 Doc/Examples/Serializer/SerializeObject.aml create mode 100644 Doc/Examples/Serializer/SerializeRawJson.aml create mode 100644 Doc/Examples/Serializer/SerializeSerializationBinder.aml create mode 100644 Doc/Examples/Serializer/SerializeTypeNameHandling.aml create mode 100644 Doc/Examples/Serializer/SerializeUnindentedJson.aml create mode 100644 Doc/Examples/Serializer/SerializeWithJsonConverters.aml create mode 100644 Doc/Examples/Serializer/SerializeWithJsonSerializerToFile.aml create mode 100644 Doc/Examples/Serializer/TraceWriter.aml rename Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/{ReferenceLoopHandlingObject.cs => PreserveReferencesHandlingObject.cs} (95%) diff --git a/Build/build.ps1 b/Build/build.ps1 index 01d06b12..ab8e0a8b 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -5,7 +5,7 @@ $version = GetVersion $majorWithReleaseVersion $signAssemblies = $false $signKeyPath = "D:\Development\Releases\newtonsoft.snk" - $buildDocumentation = $false + $buildDocumentation = $true $buildNuGet = $false $baseDir = resolve-path .. diff --git a/Doc/Examples/Examples.aml b/Doc/Examples/Examples.aml new file mode 100644 index 00000000..8d8c5375 --- /dev/null +++ b/Doc/Examples/Examples.aml @@ -0,0 +1,41 @@ + + + + + Json.NET has the ability to conditionally serialize properties by placing a ShouldSerialize method on a class. + This funtionality is similar to the +XmlSerializer ShouldSerialize feature +http://msdn.microsoft.com/en-us/library/53b8022e.aspx +_blank +. + +
+ ShouldSerialize + + To conditionally serialize a property add a boolean method with the same name as the property and then prefixed the method name + with ShouldSerialize. The result of the method determines whether the property is serialized. If the method returns true then the + property will be serialized, if it returns false and the property will be skipped. + + + + + +
+
+ IContractResolver + + ShouldSerialize can also be set using an T:Newtonsoft.Json.Serialization.IContractResolver. + Conditionally serializing a property using an IContractResolver is useful if you don't want to place a ShouldSerialize method on a class + or you didn't declare the class and are unable to. + + + + +
+ + T:Newtonsoft.Json.JsonSerializer + T:Newtonsoft.Json.Serialization.IContractResolver + P:Newtonsoft.Json.Serialization.JsonProperty.ShouldSerialize + +
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer.aml b/Doc/Examples/Serializer.aml new file mode 100644 index 00000000..29ae4f06 --- /dev/null +++ b/Doc/Examples/Serializer.aml @@ -0,0 +1,70 @@ + + + + + + The T:Newtonsoft.Json.Serialization.IContractResolver + interface provides a way to customize how the + JsonSerializer serializes and deserializes .NET objects to JSON without placing attributes on your classes. + + Anything that can be set on an object, collection, property, etc, using attributes or methods to control serialization + can also be set using an IContractResolver. + + +
+ DefaultContractResolver + + + The T:Newtonsoft.Json.Serialization.DefaultContractResolver + is the default resolver used by the + serializer. It provides many avenues of extensibility in the form of + virtual methods that can be overriden. + +
+
+ CamelCasePropertyNamesContractResolver + + + T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver + inherits from DefaultContractResolver and simply overrides the JSON + property name to be written in +camelcase +http://en.wikipedia.org/wiki/CamelCase +_blank +. + + + +
+
+ Custom IContractResolver Examples + + + + This example sets a T:Newtonsoft.Json.JsonConverter for a type + using an IContractResolver. Using a contract resolver here is useful because DateTime is not your own type and it is not possible to place a JsonConverterAttribute on it. + + + + This example sets up + conditional serialization for a property + ConditionalProperties.htm + _self + using an IContractResolver. This is useful if you want to conditionally serialize a property but don't want to add additional methods to your type. + +
+ + T:Newtonsoft.Json.Serialization.IContractResolver + T:Newtonsoft.Json.Serialization.DefaultContractResolver + T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver + +
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/CustomContractResolver.aml b/Doc/Examples/Serializer/CustomContractResolver.aml new file mode 100644 index 00000000..3c0da982 --- /dev/null +++ b/Doc/Examples/Serializer/CustomContractResolver.aml @@ -0,0 +1,16 @@ + + + + + This example creates a custom T:Newtonsoft.Json.Serialization.IContractResolver + that only serializes a type's properties that begin with a specified character. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/CustomJsonConverter.aml b/Doc/Examples/Serializer/CustomJsonConverter.aml new file mode 100644 index 00000000..4d7c6bf3 --- /dev/null +++ b/Doc/Examples/Serializer/CustomJsonConverter.aml @@ -0,0 +1,16 @@ + + + + + This example creates a custom T:Newtonsoft.Json.JsonConverter + that overrides serialization to add a keys property. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/CustomTraceWriter.aml b/Doc/Examples/Serializer/CustomTraceWriter.aml new file mode 100644 index 00000000..183f832f --- /dev/null +++ b/Doc/Examples/Serializer/CustomTraceWriter.aml @@ -0,0 +1,21 @@ + + + + + This example creates a custom T:Newtonsoft.Json.Serialization.ITraceWriter + that writes to + + NLog + http://nlog-project.org/ + _blank + . + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DataContractAndDataMember.aml b/Doc/Examples/Serializer/DataContractAndDataMember.aml new file mode 100644 index 00000000..cf75f6ad --- /dev/null +++ b/Doc/Examples/Serializer/DataContractAndDataMember.aml @@ -0,0 +1,19 @@ + + + + + This example shows how .NET Framework attributes such as + T:System.Runtime.Serialization.DataContractAttribute, + T:System.Runtime.Serialization.DataMemberAttribute and + T:System.Runtime.Serialization.NonSerializedAttribute + can be used with Json.NET instead of Json.NET's own attributes. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DefaultValueAttributeIgnore.aml b/Doc/Examples/Serializer/DefaultValueAttributeIgnore.aml new file mode 100644 index 00000000..a141c40b --- /dev/null +++ b/Doc/Examples/Serializer/DefaultValueAttributeIgnore.aml @@ -0,0 +1,17 @@ + + + + + This example uses the T:System.ComponentModel.DefaultValueAttribute + to override the default value for a property and exclude it from serialization using + T:Newtonsoft.Json.DefaultValueHandling. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DefaultValueHandlingIgnore.aml b/Doc/Examples/Serializer/DefaultValueHandlingIgnore.aml new file mode 100644 index 00000000..d20469d7 --- /dev/null +++ b/Doc/Examples/Serializer/DefaultValueHandlingIgnore.aml @@ -0,0 +1,16 @@ + + + + + This example uses the T:Newtonsoft.Json.DefaultValueHandling setting to + not serialize properties with a default value. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeAnonymousType.aml b/Doc/Examples/Serializer/DeserializeAnonymousType.aml new file mode 100644 index 00000000..3300e637 --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeAnonymousType.aml @@ -0,0 +1,14 @@ + + + + + This example deserializes JSON into an anonymous type. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeCollection.aml b/Doc/Examples/Serializer/DeserializeCollection.aml new file mode 100644 index 00000000..a432a966 --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeCollection.aml @@ -0,0 +1,14 @@ + + + + + This example deserializes JSON into a collection. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeConstructorHandling.aml b/Doc/Examples/Serializer/DeserializeConstructorHandling.aml new file mode 100644 index 00000000..5609dd30 --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeConstructorHandling.aml @@ -0,0 +1,16 @@ + + + + + This example uses the T:Newtonsoft.Json.ConstructorHandling setting to + successfully deserialize the class using its non-public constructor. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeCustomCreationConverter.aml b/Doc/Examples/Serializer/DeserializeCustomCreationConverter.aml new file mode 100644 index 00000000..844cd14d --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeCustomCreationConverter.aml @@ -0,0 +1,16 @@ + + + + + This example creates a class that inherits from T:Newtonsoft.Json.CustomCreationConverter`1 + that instantiates Employee instances for the Person type. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeDataSet.aml b/Doc/Examples/Serializer/DeserializeDataSet.aml new file mode 100644 index 00000000..0d845fae --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeDataSet.aml @@ -0,0 +1,14 @@ + + + + + This example deserializes JSON to a T:System.Data.DataSet. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeDictionary.aml b/Doc/Examples/Serializer/DeserializeDictionary.aml new file mode 100644 index 00000000..124cc8e5 --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeDictionary.aml @@ -0,0 +1,14 @@ + + + + + This example deserializes JSON into a dictionary. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeMissingMemberHandling.aml b/Doc/Examples/Serializer/DeserializeMissingMemberHandling.aml new file mode 100644 index 00000000..9708f408 --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeMissingMemberHandling.aml @@ -0,0 +1,16 @@ + + + + + This example attempts to deserialize JSON with T:Newtonsoft.Json.MissingMemberHandling + set to error and a JSON property that doesn't match to a member, causing an exception. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeObject.aml b/Doc/Examples/Serializer/DeserializeObject.aml new file mode 100644 index 00000000..77c15df1 --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeObject.aml @@ -0,0 +1,15 @@ + + + + + This example deserializes JSON to an object. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeObjectCreationHandling.aml b/Doc/Examples/Serializer/DeserializeObjectCreationHandling.aml new file mode 100644 index 00000000..5b893845 --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeObjectCreationHandling.aml @@ -0,0 +1,16 @@ + + + + + This example deserializes JSON with T:Newtonsoft.Json.ObjectCreationHandling + set to Replace so that collection values aren't duplicated. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/DeserializeWithJsonSerializerFromFile.aml b/Doc/Examples/Serializer/DeserializeWithJsonSerializerFromFile.aml new file mode 100644 index 00000000..94573713 --- /dev/null +++ b/Doc/Examples/Serializer/DeserializeWithJsonSerializerFromFile.aml @@ -0,0 +1,15 @@ + + + + + This example deserializes JSON retrieved from a file. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/ErrorHandlingAttribute.aml b/Doc/Examples/Serializer/ErrorHandlingAttribute.aml new file mode 100644 index 00000000..011708ed --- /dev/null +++ b/Doc/Examples/Serializer/ErrorHandlingAttribute.aml @@ -0,0 +1,15 @@ + + + + + This example uses T:Newtonsoft.Json.OnErrorAttribute to ignore the exception thrown setting the Roles property. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/ErrorHandlingEvent.aml b/Doc/Examples/Serializer/ErrorHandlingEvent.aml new file mode 100644 index 00000000..ea536416 --- /dev/null +++ b/Doc/Examples/Serializer/ErrorHandlingEvent.aml @@ -0,0 +1,15 @@ + + + + + This example uses the P:Newtonsoft.Json.JsonSerializerSettings.Error event + to ignore the exceptions thrown from the invalid date strings. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonConverterAttributeClass.aml b/Doc/Examples/Serializer/JsonConverterAttributeClass.aml new file mode 100644 index 00000000..7ca3d7a7 --- /dev/null +++ b/Doc/Examples/Serializer/JsonConverterAttributeClass.aml @@ -0,0 +1,18 @@ + + + + + This example uses the + T:Newtonsoft.Json.JsonConverterAttribute + to specify that a T:Newtonsoft.Json.JsonConverter + should be used when serializing and deserializing a class. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonConverterAttributeProperty.aml b/Doc/Examples/Serializer/JsonConverterAttributeProperty.aml new file mode 100644 index 00000000..5f953430 --- /dev/null +++ b/Doc/Examples/Serializer/JsonConverterAttributeProperty.aml @@ -0,0 +1,18 @@ + + + + + This example uses the + T:Newtonsoft.Json.JsonConverterAttribute + to specify that a T:Newtonsoft.Json.JsonConverter + should be used when serializing and deserializing a property. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonObjectAttributeOptIn.aml b/Doc/Examples/Serializer/JsonObjectAttributeOptIn.aml new file mode 100644 index 00000000..27a0d802 --- /dev/null +++ b/Doc/Examples/Serializer/JsonObjectAttributeOptIn.aml @@ -0,0 +1,19 @@ + + + + + This example uses + T:Newtonsoft.Json.JsonObjectAttribute + and T:Newtonsoft.Json.MemberSerialization to specify that + only properties that have been explicitly specified with T:Newtonsoft.Json.JsonPropertyAttribute + should be serialized. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonObjectAttributeOverrideIEnumerable.aml b/Doc/Examples/Serializer/JsonObjectAttributeOverrideIEnumerable.aml new file mode 100644 index 00000000..c4f33a52 --- /dev/null +++ b/Doc/Examples/Serializer/JsonObjectAttributeOverrideIEnumerable.aml @@ -0,0 +1,17 @@ + + + + + This example uses T:Newtonsoft.Json.JsonObjectAttribute + to serialize a class that implements T:System.IEnumerable`1 as + a JSON object instead of a JSON array. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonPropertyItemLevelSetting.aml b/Doc/Examples/Serializer/JsonPropertyItemLevelSetting.aml new file mode 100644 index 00000000..056c6730 --- /dev/null +++ b/Doc/Examples/Serializer/JsonPropertyItemLevelSetting.aml @@ -0,0 +1,18 @@ + + + + + This example uses T:Newtonsoft.Json.JsonPropertyAttribute + to change how the property value's items are serialized, + e.g. setting ItemIsReference to true on a property with a collection will serialize all the collection's items + with reference tracking enabled. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonPropertyName.aml b/Doc/Examples/Serializer/JsonPropertyName.aml new file mode 100644 index 00000000..7fa8a6bd --- /dev/null +++ b/Doc/Examples/Serializer/JsonPropertyName.aml @@ -0,0 +1,16 @@ + + + + + This example uses T:Newtonsoft.Json.JsonPropertyAttribute + to change the names of properties when they are serialized to JSON. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonPropertyOrder.aml b/Doc/Examples/Serializer/JsonPropertyOrder.aml new file mode 100644 index 00000000..941dee5c --- /dev/null +++ b/Doc/Examples/Serializer/JsonPropertyOrder.aml @@ -0,0 +1,16 @@ + + + + + This example uses T:Newtonsoft.Json.JsonPropertyAttribute + to order of properties when they are serialized to JSON. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonPropertyPropertyLevelSetting.aml b/Doc/Examples/Serializer/JsonPropertyPropertyLevelSetting.aml new file mode 100644 index 00000000..53f5badd --- /dev/null +++ b/Doc/Examples/Serializer/JsonPropertyPropertyLevelSetting.aml @@ -0,0 +1,16 @@ + + + + + This example uses T:Newtonsoft.Json.JsonPropertyAttribute + to change how the property value is serialized. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/JsonPropertyRequired.aml b/Doc/Examples/Serializer/JsonPropertyRequired.aml new file mode 100644 index 00000000..93fd48c7 --- /dev/null +++ b/Doc/Examples/Serializer/JsonPropertyRequired.aml @@ -0,0 +1,17 @@ + + + + + This example uses T:Newtonsoft.Json.JsonPropertyAttribute + to set T:Newtonsoft.Json.Required which is used during deserialization + to validate the presence of required JSON properties. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/MaxDepth.aml b/Doc/Examples/Serializer/MaxDepth.aml new file mode 100644 index 00000000..f7aa9e0b --- /dev/null +++ b/Doc/Examples/Serializer/MaxDepth.aml @@ -0,0 +1,15 @@ + + + + + This example uses the P:Newtonsoft.Json.JsonSerializerSettings.MaxDepth setting to constrain JSON + to a maximum depth when deserializing. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/NullValueHandlingIgnore.aml b/Doc/Examples/Serializer/NullValueHandlingIgnore.aml new file mode 100644 index 00000000..68da061a --- /dev/null +++ b/Doc/Examples/Serializer/NullValueHandlingIgnore.aml @@ -0,0 +1,16 @@ + + + + + This example serializes an object to JSON with T:Newtonsoft.Json.NullValueHandling + set to Ignore so that properties with a default value aren't included in the JSON result. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/PopulateObject.aml b/Doc/Examples/Serializer/PopulateObject.aml new file mode 100644 index 00000000..1de0cd45 --- /dev/null +++ b/Doc/Examples/Serializer/PopulateObject.aml @@ -0,0 +1,15 @@ + + + + + This example populates an existing object instance with values from JSON. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/PreserveReferencesHandlingObject.aml b/Doc/Examples/Serializer/PreserveReferencesHandlingObject.aml new file mode 100644 index 00000000..b38f5eea --- /dev/null +++ b/Doc/Examples/Serializer/PreserveReferencesHandlingObject.aml @@ -0,0 +1,16 @@ + + + + + This example shows how the T:Newtonsoft.Json.PreserveReferencesHandling + setting can be used to serialize values by reference instead of by value. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/PropertyJsonIgnore.aml b/Doc/Examples/Serializer/PropertyJsonIgnore.aml new file mode 100644 index 00000000..aa62533d --- /dev/null +++ b/Doc/Examples/Serializer/PropertyJsonIgnore.aml @@ -0,0 +1,16 @@ + + + + + This example uses the T:Newtonsoft.Json.JsonIgnoreAttribute + to exclude a property from serialization. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/ReferenceLoopHandlingIgnore.aml b/Doc/Examples/Serializer/ReferenceLoopHandlingIgnore.aml new file mode 100644 index 00000000..ac1e7784 --- /dev/null +++ b/Doc/Examples/Serializer/ReferenceLoopHandlingIgnore.aml @@ -0,0 +1,16 @@ + + + + + This example sets T:Newtonsoft.Json.ReferenceLoopHandling + to Ignore so that looping values are excluded from serialization instead of throwing an exception. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializationCallbackAttributes.aml b/Doc/Examples/Serializer/SerializationCallbackAttributes.aml new file mode 100644 index 00000000..0fe277cd --- /dev/null +++ b/Doc/Examples/Serializer/SerializationCallbackAttributes.aml @@ -0,0 +1,20 @@ + + + + + This example uses serialization callback attributes +(T:System.Runtime.Serialization.OnSerializingAttribute, +T:System.Runtime.Serialization.OnSerializedAttribute, +T:System.Runtime.Serialization.OnDeserializingAttribute, +T:System.Runtime.Serialization.OnDeserializedAttribute) + to manipulate an object before and after its serialization and deserialization. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeCollection.aml b/Doc/Examples/Serializer/SerializeCollection.aml new file mode 100644 index 00000000..9b7a5808 --- /dev/null +++ b/Doc/Examples/Serializer/SerializeCollection.aml @@ -0,0 +1,14 @@ + + + + + This example serializes a collection to JSON. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeConditionalProperty.aml b/Doc/Examples/Serializer/SerializeConditionalProperty.aml new file mode 100644 index 00000000..d640167c --- /dev/null +++ b/Doc/Examples/Serializer/SerializeConditionalProperty.aml @@ -0,0 +1,15 @@ + + + + + This example uses a conditional property to exclude a property from serialization. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeContractResolver.aml b/Doc/Examples/Serializer/SerializeContractResolver.aml new file mode 100644 index 00000000..9b2b5ec3 --- /dev/null +++ b/Doc/Examples/Serializer/SerializeContractResolver.aml @@ -0,0 +1,16 @@ + + + + + This example uses a custom T:Newtonsoft.Json.Serialization.IContractResolver + to modify how objects are serialized. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeDataSet.aml b/Doc/Examples/Serializer/SerializeDataSet.aml new file mode 100644 index 00000000..4101f56b --- /dev/null +++ b/Doc/Examples/Serializer/SerializeDataSet.aml @@ -0,0 +1,14 @@ + + + + + This example serializes a DataSet to JSON. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeDateFormatHandling.aml b/Doc/Examples/Serializer/SerializeDateFormatHandling.aml new file mode 100644 index 00000000..30fab3ad --- /dev/null +++ b/Doc/Examples/Serializer/SerializeDateFormatHandling.aml @@ -0,0 +1,15 @@ + + + + + This example uses the T:Newtonsoft.Json.DateFormatHandling + setting to control how T:System.DateTime and T:System.DateTimeOffset are serialized. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeDateTimeZoneHandling.aml b/Doc/Examples/Serializer/SerializeDateTimeZoneHandling.aml new file mode 100644 index 00000000..f3d4022a --- /dev/null +++ b/Doc/Examples/Serializer/SerializeDateTimeZoneHandling.aml @@ -0,0 +1,16 @@ + + + + + This example uses the T:Newtonsoft.Json.DateTimeZoneHandling + setting to control how T:System.DateTime and T:System.DateTimeOffset are serialized. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeDictionary.aml b/Doc/Examples/Serializer/SerializeDictionary.aml new file mode 100644 index 00000000..21f1bf34 --- /dev/null +++ b/Doc/Examples/Serializer/SerializeDictionary.aml @@ -0,0 +1,14 @@ + + + + + This example serializes a dictionary to JSON. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeObject.aml b/Doc/Examples/Serializer/SerializeObject.aml new file mode 100644 index 00000000..fc4c3c7f --- /dev/null +++ b/Doc/Examples/Serializer/SerializeObject.aml @@ -0,0 +1,15 @@ + + + + + This example serializes an object to JSON. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeRawJson.aml b/Doc/Examples/Serializer/SerializeRawJson.aml new file mode 100644 index 00000000..9bfc2280 --- /dev/null +++ b/Doc/Examples/Serializer/SerializeRawJson.aml @@ -0,0 +1,16 @@ + + + + + This example uses T:Newtonsoft.Json.Linq.JRaw + properties to serialize raw text to JSON. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeSerializationBinder.aml b/Doc/Examples/Serializer/SerializeSerializationBinder.aml new file mode 100644 index 00000000..b7c45895 --- /dev/null +++ b/Doc/Examples/Serializer/SerializeSerializationBinder.aml @@ -0,0 +1,16 @@ + + + + + This example creates a custom T:System.RunTime.Serialization.SerializationBinder + that writes only the type name when including type data in JSON. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeTypeNameHandling.aml b/Doc/Examples/Serializer/SerializeTypeNameHandling.aml new file mode 100644 index 00000000..a7ccf77e --- /dev/null +++ b/Doc/Examples/Serializer/SerializeTypeNameHandling.aml @@ -0,0 +1,16 @@ + + + + + This example uses the T:Newtonsoft.Json.TypeNameHandling + setting to include type information when serializing JSON and read type information so that the create types are created when deserializing JSON. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeUnindentedJson.aml b/Doc/Examples/Serializer/SerializeUnindentedJson.aml new file mode 100644 index 00000000..982fd9dd --- /dev/null +++ b/Doc/Examples/Serializer/SerializeUnindentedJson.aml @@ -0,0 +1,15 @@ + + + + + This example serializes an object to JSON without any formatting or indentation whitespace. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeWithJsonConverters.aml b/Doc/Examples/Serializer/SerializeWithJsonConverters.aml new file mode 100644 index 00000000..7bd169a8 --- /dev/null +++ b/Doc/Examples/Serializer/SerializeWithJsonConverters.aml @@ -0,0 +1,15 @@ + + + + + This example uses a T:Newtonsoft.Json.JsonConverter + to customize how JSON is serialized. + +
+ Example + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/SerializeWithJsonSerializerToFile.aml b/Doc/Examples/Serializer/SerializeWithJsonSerializerToFile.aml new file mode 100644 index 00000000..9feb7b62 --- /dev/null +++ b/Doc/Examples/Serializer/SerializeWithJsonSerializerToFile.aml @@ -0,0 +1,15 @@ + + + + + This example serializes JSON to a file. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/Examples/Serializer/TraceWriter.aml b/Doc/Examples/Serializer/TraceWriter.aml new file mode 100644 index 00000000..b273fc34 --- /dev/null +++ b/Doc/Examples/Serializer/TraceWriter.aml @@ -0,0 +1,16 @@ + + + + + This example uses an T:Newtonsoft.Json.Serialization.ITraceWriter + to log debug information from serialization. + +
+ Example + + + + +
+
+
\ No newline at end of file diff --git a/Doc/doc.content b/Doc/doc.content index 3c3d5b7c..145f0542 100644 --- a/Doc/doc.content +++ b/Doc/doc.content @@ -1,7 +1,7 @@  - + @@ -15,7 +15,7 @@ - + @@ -29,4 +29,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Doc/doc.shfbproj b/Doc/doc.shfbproj index 0bdcc7a0..f16fd37a 100644 --- a/Doc/doc.shfbproj +++ b/Doc/doc.shfbproj @@ -137,6 +137,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -191,6 +242,10 @@ logo + + + + \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/DeserializeWithLinq.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/DeserializeWithLinq.cs index 4d06860e..43dd2d9d 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/DeserializeWithLinq.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/DeserializeWithLinq.cs @@ -22,14 +22,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq { string json = @"[ { - ""Title"": ""Json.NET is awesome!"", - ""Author"": { - ""Name"": ""James Newton-King"", - ""Twitter"": ""@JamesNK"", - ""Picture"": ""/jamesnk.png"" + 'Title': 'Json.NET is awesome!', + 'Author': { + 'Name': 'James Newton-King', + 'Twitter': '@JamesNK', + 'Picture': '/jamesnk.png' }, - ""Date"": ""2013-01-23T19:30:00"", - ""BodyHtml"": ""<h3>Title!</h3>\r\n<p>Content!</p>"" + 'Date': '2013-01-23T19:30:00', + 'BodyHtml': '<h3>Title!</h3>\r\n<p>Content!</p>' } ]"; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ModifyJson.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ModifyJson.cs index 0fa0ea98..61473218 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ModifyJson.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ModifyJson.cs @@ -11,12 +11,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq public void Example() { string json = @"{ - ""channel"": { - ""title"": ""Star Wars"", - ""link"": ""http://www.starwars.com"", - ""description"": ""Star Wars blog."", - ""obsolete"": ""Obsolete value"", - ""item"": [] + 'channel': { + 'title': 'Star Wars', + 'link': 'http://www.starwars.com', + 'description': 'Star Wars blog.', + 'obsolete': 'Obsolete value', + 'item': [] } }"; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ParseJsonAny.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ParseJsonAny.cs index 55497b0d..47a6cf6b 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ParseJsonAny.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ParseJsonAny.cs @@ -25,7 +25,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq Console.WriteLine(t3.Type); // Null - JToken t4 = JToken.Parse(@"""A string!"""); + JToken t4 = JToken.Parse(@"'A string!'"); Console.WriteLine(t4.Type); // String diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/QueryJsonDynamic.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/QueryJsonDynamic.cs index eb6b2653..7ddd6f47 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/QueryJsonDynamic.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/QueryJsonDynamic.cs @@ -13,14 +13,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq { string json = @"[ { - ""Title"": ""Json.NET is awesome!"", - ""Author"": { - ""Name"": ""James Newton-King"", - ""Twitter"": ""@JamesNK"", - ""Picture"": ""/jamesnk.png"" + 'Title': 'Json.NET is awesome!', + 'Author': { + 'Name': 'James Newton-King', + 'Twitter': '@JamesNK', + 'Picture': '/jamesnk.png' }, - ""Date"": ""2013-01-23T19:30:00"", - ""BodyHtml"": ""<h3>Title!</h3>\r\n<p>Content!</p>"" + 'Date': '2013-01-23T19:30:00', + 'BodyHtml': '<h3>Title!</h3>\r\n<p>Content!</p>' } ]"; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ToObjectComplex.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ToObjectComplex.cs index 250e4cd3..ef3b7309 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ToObjectComplex.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/ToObjectComplex.cs @@ -16,12 +16,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq public void Example() { string json = @"{ - ""d"": [ + 'd': [ { - ""Name"": ""John Smith"" + 'Name': 'John Smith' }, { - ""Name"": ""Mike Smith"" + 'Name': 'Mike Smith' } ] }"; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Schema/RefJsonSchemaResolver.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Schema/RefJsonSchemaResolver.cs index af61ce32..3ff211da 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Schema/RefJsonSchemaResolver.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Schema/RefJsonSchemaResolver.cs @@ -15,33 +15,33 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Schema JsonSchemaResolver resolver = new JsonSchemaResolver(); schemaJson = @"{ - ""id"": ""person"", - ""type"": ""object"", - ""properties"": { - ""name"": {""type"":""string""}, - ""age"": {""type"":""integer""} + 'id': 'person', + 'type': 'object', + 'properties': { + 'name': {'type':'string'}, + 'age': {'type':'integer'} } }"; JsonSchema personSchema = JsonSchema.Parse(schemaJson, resolver); schemaJson = @"{ - ""id"": ""employee"", - ""type"": ""object"", - ""extends"": {""$ref"":""person""}, - ""properties"": { - ""salary"": {""type"":""number""}, - ""jobTitle"": {""type"":""string""} + 'id': 'employee', + 'type': 'object', + 'extends': {'$ref':'person'}, + 'properties': { + 'salary': {'type':'number'}, + 'jobTitle': {'type':'string'} } }"; JsonSchema employeeSchema = JsonSchema.Parse(schemaJson, resolver); string json = @"{ - ""name"": ""James"", - ""age"": 29, - ""salary"": 9000.01, - ""jobTitle"": ""Junior Vice President"" + 'name': 'James', + 'age': 29, + 'salary': 9000.01, + 'jobTitle': 'Junior Vice President' }"; JObject employee = JObject.Parse(json); diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomContractResolver.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomContractResolver.cs index 73c99c14..7dcf0a6a 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomContractResolver.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomContractResolver.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class CustomContractResolver { + #region Types public class DynamicContractResolver : DefaultContractResolver { private readonly char _startingWithChar; @@ -38,9 +39,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer get { return FirstName + " " + LastName; } } } + #endregion public void Example() { + #region Usage Person person = new Person { FirstName = "Dennis", @@ -63,6 +66,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // { // "LastName": "Deepwater-Diver" // } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomJsonConverter.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomJsonConverter.cs index 6f15c633..a87da6b4 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomJsonConverter.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomJsonConverter.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class CustomJsonConverter { + #region Types public class KeysJsonConverter : JsonConverter { private Type[] _types; @@ -58,9 +59,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public string LastName { get; set; } public IList Roles { get; set; } } + #endregion public void Example() { + #region Usage Employee employee = new Employee { FirstName = "James", @@ -91,6 +94,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(newEmployee.FirstName); // James + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomTraceWriter.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomTraceWriter.cs index 0f7efbed..e57d6047 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomTraceWriter.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/CustomTraceWriter.cs @@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class CustomTraceWriter { + #region Types public class NLogTraceWriter : ITraceWriter { private static readonly Logger Logger = LogManager.GetLogger("NLogTraceWriter"); @@ -49,9 +50,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer } } } + #endregion public void Example() { + #region Usage IList countries = new List { "New Zealand", @@ -72,6 +75,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Denmark", // "China" // ] + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DataContractAndDataMember.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DataContractAndDataMember.cs index 04cbf63e..a78ec5f7 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DataContractAndDataMember.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DataContractAndDataMember.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DataContractAndDataMember { + #region Usage [DataContract] public class File { @@ -20,9 +21,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [DataMember] public int Size { get; set; } } + #endregion public void Example() { + #region Usage File file = new File { Id = Guid.NewGuid(), @@ -37,6 +40,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Name": "ImportantLegalDocuments.docx", // "Size": 51200 // } + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DefaultValueAttributeIgnore.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DefaultValueAttributeIgnore.cs index 6e95ae13..d1d922d2 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DefaultValueAttributeIgnore.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DefaultValueAttributeIgnore.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DefaultValueAttributeIgnore { + #region Types public class Customer { public string FirstName { get; set; } @@ -19,9 +20,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer get { return FirstName + " " + LastName; } } } + #endregion public void Example() { + #region Usage Customer customer = new Customer(); string jsonIncludeDefaultValues = JsonConvert.SerializeObject(customer, Formatting.Indented); @@ -40,6 +43,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(jsonIgnoreDefaultValues); // {} + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DefaultValueHandlingIgnore.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DefaultValueHandlingIgnore.cs index 18f2a3fb..19e209a9 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DefaultValueHandlingIgnore.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DefaultValueHandlingIgnore.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DefaultValueHandlingIgnore { + #region Types public class Person { public string Name { get; set; } @@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public Person Partner { get; set; } public decimal? Salary { get; set; } } + #endregion public void Example() { + #region Usage Person person = new Person(); string jsonIncludeDefaultValues = JsonConvert.SerializeObject(person, Formatting.Indented); @@ -36,6 +39,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(jsonIgnoreDefaultValues); // {} + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeAnonymousType.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeAnonymousType.cs index bd34772f..d46751db 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeAnonymousType.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeAnonymousType.cs @@ -9,7 +9,8 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { - string json = @"{""Name"":""James""}"; + #region Usage + string json = @"{'Name':'James'}"; var customerDefinition = new {Name = ""}; @@ -17,6 +18,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(customer.Name); // James + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeCollection.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeCollection.cs index 65627dc5..ab2e5579 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeCollection.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeCollection.cs @@ -9,12 +9,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { - string json = @"[""Starcraft"",""Halo"",""Legend of Zelda""]"; + #region Usage + string json = @"['Starcraft','Halo','Legend of Zelda']"; List videogames = JsonConvert.DeserializeObject>(json); Console.WriteLine(string.Join(", ", videogames)); // Starcraft, Halo, Legend of Zelda + #endregion } } -} +} \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeConstructorHandling.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeConstructorHandling.cs index a7d17c10..d68d006c 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeConstructorHandling.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeConstructorHandling.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DeserializeConstructorHandling { + #region Types public class Website { public string Url { get; set; } @@ -24,10 +25,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Url = website.Url; } } + #endregion public void Example() { - string json = @"{""Url"":""http://www.google.com""}"; + #region Usage + string json = @"{'Url':'http://www.google.com'}"; try { @@ -46,6 +49,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(website.Url); // http://www.google.com + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeCustomCreationConverter.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeCustomCreationConverter.cs index fcd38faf..09210928 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeCustomCreationConverter.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeCustomCreationConverter.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DeserializeCustomCreationConverter { + #region Types public class Person { public string FirstName { get; set; } @@ -28,15 +29,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer return new Employee(); } } + #endregion public void Example() { + #region Usage string json = @"{ - ""Department"": ""Furniture"", - ""JobTitle"": ""Carpenter"", - ""FirstName"": ""John"", - ""LastName"": ""Joinery"", - ""BirthDate"": ""1983-02-02T00:00:00"" + 'Department': 'Furniture', + 'JobTitle': 'Carpenter', + 'FirstName': 'John', + 'LastName': 'Joinery', + 'BirthDate': '1983-02-02T00:00:00' }"; Person person = JsonConvert.DeserializeObject(json, new PersonConverter()); @@ -48,6 +51,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(employee.JobTitle); // Capenter + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeDataSet.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeDataSet.cs index 8d03f32c..c2f10095 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeDataSet.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeDataSet.cs @@ -11,15 +11,16 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage string json = @"{ - ""Table1"": [ + 'Table1': [ { - ""id"": 0, - ""item"": ""item 0"" + 'id': 0, + 'item': 'item 0' }, { - ""id"": 1, - ""item"": ""item 1"" + 'id': 1, + 'item': 'item 1' } ] }"; @@ -37,6 +38,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer } // 0 - item 0 // 1 - item 1 + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeDictionary.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeDictionary.cs index 160716f3..fa35ceb3 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeDictionary.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeDictionary.cs @@ -9,9 +9,10 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage string json = @"{ - ""href"": ""/account/login.aspx"", - ""target"": ""_blank"" + 'href': '/account/login.aspx', + 'target': '_blank' }"; Dictionary htmlAttributes = JsonConvert.DeserializeObject>(json); @@ -21,6 +22,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(htmlAttributes["target"]); // _blank + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeMissingMemberHandling.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeMissingMemberHandling.cs index 1dfe3ff6..5010ab57 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeMissingMemberHandling.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeMissingMemberHandling.cs @@ -7,18 +7,21 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DeserializeMissingMemberHandling { + #region Types public class Account { public string FullName { get; set; } public bool Deleted { get; set; } } + #endregion public void Example() { + #region Usage string json = @"{ - ""FullName"": ""Dan Deleted"", - ""Deleted"": true, - ""DeletedDate"": ""2013-01-20T00:00:00"" + 'FullName': 'Dan Deleted', + 'Deleted': true, + 'DeletedDate': '2013-01-20T00:00:00' }"; try @@ -28,10 +31,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer MissingMemberHandling = MissingMemberHandling.Error }); } - catch (JsonSerializationException) + catch (JsonSerializationException ex) { + Console.WriteLine(ex.Message); // Could not find member 'DeletedDate' on object of type 'Account'. Path 'DeletedDate', line 4, position 23. } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeObject.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeObject.cs index c38a9dd3..de40f08d 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeObject.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeObject.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DeserializeObject { + #region Types public class Account { public string Email { get; set; } @@ -14,16 +15,18 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public DateTime CreatedDate { get; set; } public IList Roles { get; set; } } + #endregion public void Example() { + #region Usage string json = @"{ - ""Email"": ""james@example.com"", - ""Active"": true, - ""CreatedDate"": ""2013-01-20T00:00:00Z"", - ""Roles"": [ - ""User"", - ""Admin"" + 'Email': 'james@example.com', + 'Active': true, + 'CreatedDate': '2013-01-20T00:00:00Z', + 'Roles': [ + 'User', + 'Admin' ] }"; @@ -31,6 +34,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(account.Email); // james@example.com + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeObjectCreationHandling.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeObjectCreationHandling.cs index 44f59949..139b4209 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeObjectCreationHandling.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeObjectCreationHandling.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DeserializeObjectCreationHandling { + #region Types public class UserViewModel { public string Name { get; set; } @@ -22,15 +23,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer }; } } + #endregion public void Example() { + #region Usage string json = @"{ - ""Name"": ""James"", - ""Offices"": [ - ""Auckland"", - ""Wellington"", - ""Christchurch"" + 'Name': 'James', + 'Offices': [ + 'Auckland', + 'Wellington', + 'Christchurch' ] }"; @@ -59,6 +62,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // Auckland // Wellington // Christchurch + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeWithJsonSerializerFromFile.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeWithJsonSerializerFromFile.cs index cf46f9e3..dcf7afaf 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeWithJsonSerializerFromFile.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/DeserializeWithJsonSerializerFromFile.cs @@ -9,14 +9,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class DeserializeWithJsonSerializerFromFile { + #region Types public class Movie { public string Name { get; set; } public int Year { get; set; } } + #endregion public void Example() { + #region Usage // read file into a string and deserialize JSON to a type Movie movie1 = JsonConvert.DeserializeObject(File.ReadAllText(@"c:\movie.json")); @@ -26,6 +29,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer JsonSerializer serializer = new JsonSerializer(); Movie movie2 = (Movie)serializer.Deserialize(file, typeof (Movie)); } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ErrorHandlingAttribute.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ErrorHandlingAttribute.cs index 2ca8aa14..ccbc18d6 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ErrorHandlingAttribute.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ErrorHandlingAttribute.cs @@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class ErrorHandlingAttribute { + #region Types public class Employee { private List _roles; @@ -34,9 +35,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer errorContext.Handled = true; } } + #endregion public void Example() { + #region Usage Employee person = new Employee { Name = "George Michael Bluth", @@ -53,6 +56,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Age": 16, // "Title": "Mister Manager" // } + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ErrorHandlingEvent.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ErrorHandlingEvent.cs index f9882a1e..1fd2b0d5 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ErrorHandlingEvent.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ErrorHandlingEvent.cs @@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage List errors = new List(); List c = JsonConvert.DeserializeObject>(@"[ @@ -40,6 +41,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // The string was not recognized as a valid DateTime. There is a unknown word starting at index 0. // Unexpected token parsing date. Expected String, got StartArray. // Cannot convert null value to System.DateTime. + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonConverterAttributeClass.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonConverterAttributeClass.cs index be4f3cf3..56c95d56 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonConverterAttributeClass.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonConverterAttributeClass.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonConverterAttributeClass { + #region Types public class UserConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) @@ -36,9 +37,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public string UserName { get; set; } } + #endregion public void Example() { + #region Usage User user = new User { UserName = @"domain\username" @@ -48,6 +51,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(json); // "domain\\username" + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonConverterAttributeProperty.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonConverterAttributeProperty.cs index e48e0ba9..5f14448c 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonConverterAttributeProperty.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonConverterAttributeProperty.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonConverterAttributeProperty { + #region Types public enum UserStatus { NotConfirmed, @@ -22,9 +23,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [JsonConverter(typeof(StringEnumConverter))] public UserStatus Status { get; set; } } + #endregion public void Example() { + #region Usage User user = new User { UserName = @"domain\username", @@ -38,6 +41,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "UserName": "domain\\username", // "Status": "Deleted" // } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonObjectAttributeOptIn.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonObjectAttributeOptIn.cs index bf5503de..028a4eb1 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonObjectAttributeOptIn.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonObjectAttributeOptIn.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonObjectAttributeOptIn { + #region Types [JsonObject(MemberSerialization.OptIn)] public class File { @@ -19,9 +20,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [JsonProperty] public int Size { get; set; } } + #endregion public void Example() { + #region Usage File file = new File { Id = Guid.NewGuid(), @@ -36,6 +39,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Name": "ImportantLegalDocuments.docx", // "Size": 51200 // } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonObjectAttributeOverrideIEnumerable.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonObjectAttributeOverrideIEnumerable.cs index 8dc5e349..196c4333 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonObjectAttributeOverrideIEnumerable.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonObjectAttributeOverrideIEnumerable.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonObjectAttributeOverrideIEnumerable { + #region Types [JsonObject] public class Directory : IEnumerable { @@ -29,9 +30,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer return GetEnumerator(); } } + #endregion public void Example() { + #region Usage Directory directory = new Directory { Name = "My Documents", @@ -52,6 +55,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "WiseFinancalAdvice.xlsx" // ] // } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyItemLevelSetting.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyItemLevelSetting.cs index 04abd018..d6709b34 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyItemLevelSetting.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyItemLevelSetting.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonPropertyItemLevelSetting { + #region Types public class Business { public string Name { get; set; } @@ -22,9 +23,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [JsonProperty(IsReference = true)] public Employee Manager { get; set; } } + #endregion public void Example() { + #region Usage Employee manager = new Employee { Name = "George-Michael" @@ -65,6 +68,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // } // ] // } + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyName.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyName.cs index 45af1439..dcf9d56f 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyName.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyName.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonPropertyName { + #region Types public class Videogame { [JsonProperty("name")] @@ -15,9 +16,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [JsonProperty("release_date")] public DateTime ReleaseDate { get; set; } } + #endregion public void Example() { + #region Usage Videogame starcraft = new Videogame { Name = "Starcraft", @@ -31,6 +34,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "name": "Starcraft", // "release_date": "1998-01-01T00:00:00" // } + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyOrder.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyOrder.cs index dfbdbdae..ccfe6068 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyOrder.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyOrder.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonPropertyOrder { + #region Types public class Account { public string EmailAddress { get; set; } @@ -24,9 +25,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [JsonProperty(Order = -2)] public string FullName { get; set; } } + #endregion public void Example() { + #region Usage Account account = new Account { FullName = "Aaron Account", @@ -48,6 +51,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Deleted": true, // "DeletedDate": "2013-01-25T00:00:00" // } + #endregion } } -} +} \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyPropertyLevelSetting.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyPropertyLevelSetting.cs index e9ba7012..3f4b0b48 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyPropertyLevelSetting.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyPropertyLevelSetting.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonPropertyPropertyLevelSetting { + #region Types public class Vessel { public string Name { get; set; } @@ -15,9 +16,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public DateTime? LaunchDate { get; set; } } + #endregion public void Example() { + #region Usage Vessel vessel = new Vessel { Name = "Red October", @@ -31,6 +34,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Name": "Red October", // "Class": "Typhoon" // } + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyRequired.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyRequired.cs index b223673a..4a17e6ff 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyRequired.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/JsonPropertyRequired.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class JsonPropertyRequired { + #region Types public class Videogame { [JsonProperty(Required = Required.Always)] @@ -15,12 +16,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [JsonProperty(Required = Required.AllowNull)] public DateTime? ReleaseDate { get; set; } } + #endregion public void Example() { + #region Usage string json = @"{ - ""Name"": ""Starcraft III"", - ""ReleaseDate"": null + 'Name': 'Starcraft III', + 'ReleaseDate': null }"; Videogame starcraft = JsonConvert.DeserializeObject(json); @@ -30,6 +33,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(starcraft.ReleaseDate); // null + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/MaxDepth.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/MaxDepth.cs index eb344c69..2cf7360d 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/MaxDepth.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/MaxDepth.cs @@ -9,12 +9,13 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage string json = @"[ [ [ - ""1"", - ""Two"", - ""III"" + '1', + 'Two', + 'III' ] ] ]"; @@ -31,6 +32,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(ex.Message); // The reader's MaxDepth of 2 has been exceeded. Path '[0][0]', line 3, position 12. } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/NullValueHandlingIgnore.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/NullValueHandlingIgnore.cs index 05a5af46..a676cba5 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/NullValueHandlingIgnore.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/NullValueHandlingIgnore.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class NullValueHandlingIgnore { + #region Types public class Person { public string Name { get; set; } @@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public Person Partner { get; set; } public decimal? Salary { get; set; } } + #endregion public void Example() { + #region Usage Person person = new Person { Name = "Nigal Newborn", @@ -43,6 +46,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Name": "Nigal Newborn", // "Age": 1 // } + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PopulateObject.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PopulateObject.cs index bcf90967..ad0137cb 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PopulateObject.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PopulateObject.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class PopulateObject { + #region Types public class Account { public string Email { get; set; } @@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public DateTime CreatedDate { get; set; } public IList Roles { get; set; } } + #endregion public void Example() { + #region Usage Account account = new Account { Email = "james@example.com", @@ -30,9 +33,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer }; string json = @"{ - ""Active"": false, - ""Roles"": [ - ""Expired"" + 'Active': false, + 'Roles': [ + 'Expired' ] }"; @@ -46,6 +49,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(string.Join(", ", account.Roles)); // User, Admin, Expired + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ReferenceLoopHandlingObject.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PreserveReferencesHandlingObject.cs similarity index 95% rename from Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ReferenceLoopHandlingObject.cs rename to Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PreserveReferencesHandlingObject.cs index 7bbf717e..1785539c 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ReferenceLoopHandlingObject.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PreserveReferencesHandlingObject.cs @@ -5,8 +5,9 @@ using System.Text; namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { - public class ReferenceLoopHandlingObject + public class PreserveReferencesHandlingObject { + #region Types public class Directory { public string Name { get; set; } @@ -19,9 +20,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public string Name { get; set; } public Directory Parent { get; set; } } + #endregion public void Example() { + #region Usage Directory root = new Directory { Name = "Root" }; Directory documents = new Directory { Name = "My Documents", Parent = root }; @@ -93,6 +96,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // } // ] // } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PropertyJsonIgnore.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PropertyJsonIgnore.cs index f974662e..a76a0209 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PropertyJsonIgnore.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/PropertyJsonIgnore.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class PropertyJsonIgnore { + #region Types public class Account { public string FullName { get; set; } @@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer [JsonIgnore] public string PasswordHash { get; set; } } + #endregion public void Example() { + #region Usage Account account = new Account { FullName = "Joe User", @@ -28,6 +31,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(json); // {"FullName":"Joe User","EmailAddress":"joe@example.com"} + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ReferenceLoopHandlingIgnore.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ReferenceLoopHandlingIgnore.cs index 0e8a8e47..117fc265 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ReferenceLoopHandlingIgnore.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/ReferenceLoopHandlingIgnore.cs @@ -7,14 +7,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class ReferenceLoopHandlingIgnore { + #region Types public class Employee { public string Name { get; set; } public Employee Manager { get; set; } } + #endregion public void Example() { + #region Usage Employee joe = new Employee { Name = "Joe User" }; Employee mike = new Employee { Name = "Mike Manager" }; joe.Manager = mike; @@ -32,6 +35,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Name": "Mike Manager" // } // } + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializationCallbackAttributes.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializationCallbackAttributes.cs index 34c34fe4..670bbadd 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializationCallbackAttributes.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializationCallbackAttributes.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializationCallbackAttributes { + #region Types public class SerializationEventTestObject { // 2222 @@ -58,9 +59,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Member4 = "This value was set after deserialization."; } } + #endregion public void Example() { + #region Usage SerializationEventTestObject obj = new SerializationEventTestObject(); Console.WriteLine(obj.Member1); @@ -98,6 +101,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // This value was set during deserialization Console.WriteLine(obj.Member4); // This value was set after deserialization. + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeCollection.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeCollection.cs index bee2b95a..7e8c3c90 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeCollection.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeCollection.cs @@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage List videogames = new List { "Starcraft", @@ -20,6 +21,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(json); // ["Starcraft","Halo","Legend of Zelda"] + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeConditionalProperty.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeConditionalProperty.cs index e5ada9db..4a7cf7bb 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeConditionalProperty.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeConditionalProperty.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeConditionalProperty { + #region Types public class Employee { public string Name { get; set; } @@ -18,9 +19,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer return (Manager != this); } } + #endregion public void Example() { + #region Usage Employee joe = new Employee(); joe.Name = "Joe Employee"; Employee mike = new Employee(); @@ -33,6 +36,8 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer mike.Manager = mike; string json = JsonConvert.SerializeObject(new[] { joe, mike }, Formatting.Indented); + + Console.WriteLine(json); // [ // { // "Name": "Joe Employee", @@ -44,6 +49,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Name": "Mike Manager" // } // ] + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeContractResolver.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeContractResolver.cs index 071f8176..37f632cc 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeContractResolver.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeContractResolver.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeContractResolver { + #region Types public class Person { public string FirstName { get; set; } @@ -18,9 +19,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer get { return FirstName + " " + LastName; } } } + #endregion public void Example() { + #region Usage Person person = new Person { FirstName = "Sarah", @@ -38,6 +41,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "lastName": "Security", // "fullName": "Sarah Security" // } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDataSet.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDataSet.cs index ad1f2e44..d9eb1552 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDataSet.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDataSet.cs @@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage DataSet dataSet = new DataSet("dataSet"); dataSet.Namespace = "NetFrameWork"; DataTable table = new DataTable(); @@ -46,6 +47,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // } // ] // } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDateFormatHandling.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDateFormatHandling.cs index 8171b0e3..c6816f7e 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDateFormatHandling.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDateFormatHandling.cs @@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage DateTime mayanEndOfTheWorld = new DateTime(2012, 12, 21); string jsonIsoDate = JsonConvert.SerializeObject(mayanEndOfTheWorld); @@ -23,6 +24,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(jsonMsDate); // "\/Date(1356044400000+0100)\/" + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDateTimeZoneHandling.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDateTimeZoneHandling.cs index ddd990f5..088f77c6 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDateTimeZoneHandling.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDateTimeZoneHandling.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeDateTimeZoneHandling { + #region Types public class Flight { public string Destination { get; set; } @@ -15,9 +16,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public DateTime DepartureDateLocal { get; set; } public TimeSpan Duration { get; set; } } + #endregion public void Example() { + #region Usage Flight flight = new Flight { Destination = "Dubai", @@ -82,6 +85,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "DepartureDateLocal": "2013-01-21T00:00:00", // "Duration": "05:30:00" // } + #endregion } } -} +} \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDictionary.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDictionary.cs index 70fdafe4..65f59198 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDictionary.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeDictionary.cs @@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage Dictionary points = new Dictionary { { "James", 9001 }, @@ -24,6 +25,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "Jo": 3474, // "Jess": 11926 // } + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeObject.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeObject.cs index 1b5da82e..c81083eb 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeObject.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeObject.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeObject { + #region Types public class Account { public string Email { get; set; } @@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public DateTime CreatedDate { get; set; } public IList Roles { get; set; } } + #endregion public void Example() { + #region Usage Account account = new Account { Email = "james@example.com", @@ -41,6 +44,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // } Console.WriteLine(json); + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeRawJson.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeRawJson.cs index d54705c2..14fcdea9 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeRawJson.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeRawJson.cs @@ -8,14 +8,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeRawJson { + #region Types public class JavaScriptSettings { public JRaw OnLoadFunction { get; set; } public JRaw OnUnloadFunction { get; set; } } + #endregion public void Example() { + #region Usage JavaScriptSettings settings = new JavaScriptSettings { OnLoadFunction = new JRaw("OnLoad"), @@ -29,6 +32,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // "OnLoadFunction": OnLoad, // "OnUnloadFunction": function(e) { alert(e); } // } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeSerializationBinder.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeSerializationBinder.cs index 34c6638e..c39bc719 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeSerializationBinder.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeSerializationBinder.cs @@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeSerializationBinder { + #region Types public class KnownTypesBinder : SerializationBinder { public IList KnownTypes { get; set; } @@ -29,9 +30,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public string Maker { get; set; } public string Model { get; set; } } + #endregion public void Example() { + #region Usage KnownTypesBinder knownTypesBinder = new KnownTypesBinder { KnownTypes = new List {typeof (Car)} @@ -64,6 +67,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(newValue.GetType().Name); // Car + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeTypeNameHandling.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeTypeNameHandling.cs index 0e7b0768..8ed51d0d 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeTypeNameHandling.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeTypeNameHandling.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeTypeNameHandling { + #region Types public abstract class Business { public string Name { get; set; } @@ -22,9 +23,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public string FullName { get; set; } public IList Businesses { get; set; } } + #endregion public void Example() { + #region Usage Stockholder stockholder = new Stockholder { FullName = "Steve Stockholder", @@ -84,6 +87,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(newStockholder.Businesses[0].GetType().Name); // Hotel + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeUnindentedJson.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeUnindentedJson.cs index 30e774ed..7c4805ed 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeUnindentedJson.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeUnindentedJson.cs @@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeUnindentedJson { + #region Types public class Account { public string Email { get; set; } @@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer public DateTime CreatedDate { get; set; } public IList Roles { get; set; } } + #endregion public void Example() { + #region Usage Account account = new Account { Email = "james@example.com", @@ -33,6 +36,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // {"Email":"james@example.com","Active":true,"CreatedDate":"2013-01-20T00:00:00Z","Roles":["User","Admin"]} Console.WriteLine(json); + #endregion } } } diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeWithJsonConverters.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeWithJsonConverters.cs index a2e148dd..707daaf8 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeWithJsonConverters.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeWithJsonConverters.cs @@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public void Example() { + #region Usage List stringComparisons = new List { StringComparison.CurrentCulture, @@ -30,6 +31,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer Console.WriteLine(string.Join(", ", newStringComparsions.Select(c => c.ToString()))); // CurrentCulture, InvariantCulture + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeWithJsonSerializerToFile.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeWithJsonSerializerToFile.cs index b45cf3f5..89a9026a 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeWithJsonSerializerToFile.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/SerializeWithJsonSerializerToFile.cs @@ -9,14 +9,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class SerializeWithJsonSerializerToFile { + #region Types public class Movie { public string Name { get; set; } public int Year { get; set; } } + #endregion public void Example() { + #region Usage Movie movie = new Movie { Name = "Bad Boys", @@ -32,6 +35,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, movie); } + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/TraceWriter.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/TraceWriter.cs index b35d8a1a..c1099340 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/TraceWriter.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Serializer/TraceWriter.cs @@ -8,18 +8,21 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer { public class TraceWriter { + #region Types public class Account { public string FullName { get; set; } public bool Deleted { get; set; } } + #endregion public void Example() { + #region Usage string json = @"{ - ""FullName"": ""Dan Deleted"", - ""Deleted"": true, - ""DeletedDate"": ""2013-01-20T00:00:00"" + 'FullName': 'Dan Deleted', + 'Deleted': true, + 'DeletedDate': '2013-01-20T00:00:00' }"; MemoryTraceWriter traceWriter = new MemoryTraceWriter(); @@ -33,6 +36,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer // 2013-01-21T01:36:24.422 Info Started deserializing Newtonsoft.Json.Tests.Documentation.Examples.TraceWriter+Account. Path 'FullName', line 2, position 20. // 2013-01-21T01:36:24.442 Verbose Could not find member 'DeletedDate' on Newtonsoft.Json.Tests.Documentation.Examples.TraceWriter+Account. Path 'DeletedDate', line 4, position 23. // 2013-01-21T01:36:24.447 Info Finished deserializing Newtonsoft.Json.Tests.Documentation.Examples.TraceWriter+Account. Path '', line 5, position 8. + #endregion } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Xml/ConvertJsonToXml.cs b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Xml/ConvertJsonToXml.cs index 9394901e..d6cbf2a3 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Examples/Xml/ConvertJsonToXml.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Examples/Xml/ConvertJsonToXml.cs @@ -11,18 +11,18 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Xml public void Example() { string json = @"{ - ""@Id"": 1, - ""Email"": ""james@example.com"", - ""Active"": true, - ""CreatedDate"": ""2013-01-20T00:00:00Z"", - ""Roles"": [ - ""User"", - ""Admin"" + '@Id': 1, + 'Email': 'james@example.com', + 'Active': true, + 'CreatedDate': '2013-01-20T00:00:00Z', + 'Roles': [ + 'User', + 'Admin' ], - ""Team"": { - ""@Id"": 2, - ""Name"": ""Software Developers"", - ""Description"": ""Creators of fine software products and services."" + 'Team': { + '@Id': 2, + 'Name': 'Software Developers', + 'Description': 'Creators of fine software products and services.' } }"; diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj index 86a2aae4..5393d246 100644 --- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj +++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj @@ -200,7 +200,7 @@ - + diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs index 4387c8ee..59511a74 100644 --- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs @@ -76,5 +76,5 @@ using System.Security; // by using the '*' as shown below: [assembly: AssemblyVersion("4.5.0.0")] #if !PocketPC -[assembly: AssemblyFileVersion("4.5.11.15725")] +[assembly: AssemblyFileVersion("4.5.11.15726")] #endif diff --git a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs index f5309904..e7a6c8d7 100644 --- a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs @@ -90,7 +90,7 @@ using System.Security; // by using the '*' as shown below: [assembly: AssemblyVersion("4.5.0.0")] #if !PocketPC -[assembly: AssemblyFileVersion("4.5.11.15725")] +[assembly: AssemblyFileVersion("4.5.11.15726")] #endif [assembly: CLSCompliant(true)]