Merge branch 'master' of github.com:JamesNK/Newtonsoft.Json

This commit is contained in:
James Newton-King
2012-03-31 14:39:01 +13:00
16 changed files with 819 additions and 677 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>Newtonsoft.Json</id> <id>Newtonsoft.Json</id>
<version>4.0.8</version> <version>4.5.1</version>
<title>Json.NET</title> <title>Json.NET</title>
<description>Json.NET is a popular high-performance JSON framework for .NET</description> <description>Json.NET is a popular high-performance JSON framework for .NET</description>
<authors>James Newton-King</authors> <authors>James Newton-King</authors>
+10 -8
View File
@@ -1,7 +1,8 @@
properties { properties {
$zipFileName = "Json40r8.zip" $zipFileName = "Json45r1.zip"
$majorVersion = "4.0.8" $majorVersion = "4.5"
$version = GetVersion $majorVersion $majorWithReleaseVersion = "4.5.1"
$version = GetVersion $majorWithReleaseVersion
$signAssemblies = $false $signAssemblies = $false
$signKeyPath = "D:\Development\Releases\newtonsoft.snk" $signKeyPath = "D:\Development\Releases\newtonsoft.snk"
$buildDocumentation = $false $buildDocumentation = $false
@@ -16,6 +17,7 @@
$workingDir = "$baseDir\Working" $workingDir = "$baseDir\Working"
$builds = @( $builds = @(
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"; Sign=$true}, @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"; Sign=$true},
@{Name = "Newtonsoft.Json.Metro"; TestsName = $null; Constants="NETFX_CORE"; FinalDir="Metro"; NuGetDir = "winrt45"; Framework="net-4.5"; Sign=$true},
# unsigned SL/WP # unsigned SL/WP
@{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "sl3-wp,sl4-windowsphone71"; Framework="net-4.0"; Sign=$false}, @{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "sl3-wp,sl4-windowsphone71"; Framework="net-4.0"; Sign=$false},
@@ -51,7 +53,7 @@ task Clean {
task Build -depends Clean { task Build -depends Clean {
Write-Host -ForegroundColor Green "Updating assembly version" Write-Host -ForegroundColor Green "Updating assembly version"
Write-Host Write-Host
Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0') $version Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0.0') $version
foreach ($build in $builds) foreach ($build in $builds)
{ {
@@ -62,7 +64,7 @@ task Build -depends Clean {
Write-Host -ForegroundColor Green "Building " $name Write-Host -ForegroundColor Green "Building " $name
Write-Host -ForegroundColor Green "Signed " $sign Write-Host -ForegroundColor Green "Signed " $sign
Write-Host Write-Host
exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$sign" (GetConstants $build.Constants $sign) ".\Src\$name.sln" } "Error building $name" exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release "/p:Platform=Any CPU" /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$sign" (GetConstants $build.Constants $sign) ".\Src\$name.sln" } "Error building $name"
} }
} }
@@ -73,7 +75,7 @@ task Package -depends Build {
$name = $build.TestsName $name = $build.TestsName
$finalDir = $build.FinalDir $finalDir = $build.FinalDir
robocopy "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" $workingDir\Package\Bin\$finalDir /NP /XO robocopy "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" $workingDir\Package\Bin\$finalDir /NP /XO /XF *.pri
} }
if ($buildNuGet) if ($buildNuGet)
@@ -91,7 +93,7 @@ task Package -depends Build {
foreach ($frameworkDir in $frameworkDirs) foreach ($frameworkDir in $frameworkDirs)
{ {
robocopy "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" $workingDir\NuGet\lib\$frameworkDir /NP /XO robocopy "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" $workingDir\NuGet\lib\$frameworkDir /NP /XO /XF *.pri
} }
} }
} }
@@ -117,7 +119,7 @@ task Package -depends Build {
Copy-Item -Path $docDir\readme.txt -Destination $workingDir\Package\ Copy-Item -Path $docDir\readme.txt -Destination $workingDir\Package\
Copy-Item -Path $docDir\versions.txt -Destination $workingDir\Package\Bin\ Copy-Item -Path $docDir\versions.txt -Destination $workingDir\Package\Bin\
robocopy $sourceDir $workingDir\Package\Source\Src /MIR /NP /XD .svn bin obj /XF *.suo *.user robocopy $sourceDir $workingDir\Package\Source\Src /MIR /NP /XD .svn bin obj TestResults AppPackages /XF *.suo *.user
robocopy $buildDir $workingDir\Package\Source\Build /MIR /NP /XD .svn robocopy $buildDir $workingDir\Package\Source\Build /MIR /NP /XD .svn
robocopy $docDir $workingDir\Package\Source\Doc /MIR /NP /XD .svn robocopy $docDir $workingDir\Package\Source\Doc /MIR /NP /XD .svn
robocopy $toolsDir $workingDir\Package\Source\Tools /MIR /NP /XD .svn robocopy $toolsDir $workingDir\Package\Source\Tools /MIR /NP /XD .svn
+9 -2
View File
@@ -17,7 +17,12 @@
<p>DateTimes in JSON are hard.</p> <p>DateTimes in JSON are hard.</p>
<p> <p>
The problem comes from the <a href="http://www.ietf.org/rfc/rfc4627.txt" target="_blank">JSON spec</a> itself, there is no literal syntax for dates in JSON. The spec has objects, arrays, strings, integers and floats, but it defines no standard for what a date looks like.</p> The problem comes from the <a href="http://www.ietf.org/rfc/rfc4627.txt" target="_blank">JSON spec</a> itself, there is no literal syntax for dates in JSON. The spec has objects, arrays, strings, integers and floats, but it defines no standard for what a date looks like.</p>
<p>The default format used by <a href="http://james.newtonking.com/projects/json-net.aspx" target="_blank">Json.NET</a> for dates is the same one used by Microsoft: "\/Date(1198908717056)\/". You can read more about it <a href="http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx" target="_blank">here</a>.</p> <p>The default format used by <a href="http://james.newtonking.com/projects/json-net.aspx" target="_blank">Json.NET</a>
is the ISO 8601 standard: 2012-03-19T07:22Z. You can read more about it <a href="http://en.wikipedia.org/wiki/ISO_8601" target="_blank">here</a>.</p>
<p>Prior to Json.NET 4.5 dates were written using the Microsoft format:
&quot;\/Date(1198908717056)\/&quot;. If you want to use this format, or you want to
maintain compatibility with Microsoft JSON serializers or older versions of
Json.NET then change the DateFormatHandling setting to MicrosoftDateFormat.</p>
<h3>DateTime JsonConverters</h3> <h3>DateTime JsonConverters</h3>
<p>With no standard for dates in JSON, the number of possible different formats when interoping with other systems is endless. Fortunately Json.NET has a solution to deal with reading and writing custom dates: JsonConverters. A JsonConverter is used to override how a type is serialized.</p> <p>With no standard for dates in JSON, the number of possible different formats when interoping with other systems is endless. Fortunately Json.NET has a solution to deal with reading and writing custom dates: JsonConverters. A JsonConverter is used to override how a type is serialized.</p>
@@ -72,7 +77,9 @@
</div> </div>
<p>Technically this is invalid JSON according to the spec but all browsers, and some JSON frameworks including Json.NET, support it. </p> <p>Technically this is invalid JSON according to the spec but all browsers, and some JSON frameworks including Json.NET, support it. </p>
<h4>IsoDateTimeConverter</h4> <h4>IsoDateTimeConverter</h4>
<p>IsoDateTimeConverter seralizes a DateTime to an <a href="http://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> formatted string.</p> <p>IsoDateTimeConverter seralizes a DateTime to an <a href="http://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> formatted string.
Note that since Json.NET 4.5 dates are written using the ISO 8601 format by
default and using this converter is unnecessary.</p>
<div class="overflowpanel"> <div class="overflowpanel">
<div class="code"> <div class="code">
<div style="font-size: 10pt; color: black; font-family: courier new;"> <div style="font-size: 10pt; color: black; font-family: courier new;">
+37 -1
View File
@@ -19,7 +19,43 @@
JSON. These can also be used with the methods on JsonConvert via the JSON. These can also be used with the methods on JsonConvert via the
JsonSerializerSettings overloads.</p> JsonSerializerSettings overloads.</p>
<h3>MissingMemberHandling</h3> <h3>DateFormatHandling</h3>
<p>DateFormatHandling controls how dates are serialized.</p>
<table class="members">
<tbody>
<tr>
<th class="nameColumn">
Member
</th>
<th class="descriptionColumn">
Description
</th>
</tr>
<tr>
<td>
<b>IsoDateFormat</b>
</td>
<td>
<div class="summary">
By default Json.NET writes dates in the ISO 8601 format, e.g. "2012-03-21T05:40Z".
</div>
<br>
</td>
</tr>
<tr>
<td>
<b>MicrosoftDateFormat</b>
</td>
<td>
<div class="summary">
Dates are written in the Microsoft JSON format, e.g. "\/Date(1198908717056)\/".
</div>
<br>
</td>
</tr>
</tbody>
</table>
<h3>MissingMemberHandling</h3>
<p>MissingMemberHandling controls how missing members, e.g. JSON contains a property <p>MissingMemberHandling controls how missing members, e.g. JSON contains a property
that isn&#39;t a member on the object, are handled during deserialization.</p> that isn&#39;t a member on the object, are handled during deserialization.</p>
<table class="members"> <table class="members">
+4 -1
View File
@@ -3,7 +3,7 @@ Versions:
Json.NET comes in different versions for the various .NET frameworks. Json.NET comes in different versions for the various .NET frameworks.
-Net40: -Net40:
.NET latest (4.0) .NET latest (4.0 & 4.5)
-Net35: -Net35:
.NET 3.5 SP1, Mono .NET 3.5 SP1, Mono
@@ -17,6 +17,9 @@ Json.NET comes in different versions for the various .NET frameworks.
-WindowsPhone: -WindowsPhone:
Windows Phone 7 & 7.1 Windows Phone 7 & 7.1
-Metro
Windows 8 Metro, WinRT 4.5
Notes: Notes:
@@ -43,6 +43,7 @@ using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
using System.IO;
namespace Newtonsoft.Json.Tests.Linq namespace Newtonsoft.Json.Tests.Linq
{ {
@@ -21,7 +21,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\Metro\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants> <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@@ -29,7 +29,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\Metro\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants> <DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@@ -0,0 +1,76 @@
#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
#if WINDOWS_PHONE
[assembly: AssemblyTitle("Json.NET Tests Windows Phone")]
#elif SILVERLIGHT
[assembly: AssemblyTitle("Json.NET Tests Silverlight")]
#elif PocketPC
[assembly: AssemblyTitle("Json.NET Tests Compact")]
#elif NET20
[assembly: AssemblyTitle("Json.NET Tests .NET 2.0")]
#elif NET35
[assembly: AssemblyTitle("Json.NET Tests .NET 3.5")]
#else
[assembly: AssemblyTitle("Json.NET")]
#endif
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Newtonsoft")]
[assembly: AssemblyProduct("Json.NET Tests")]
[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0be3d72b-d2ef-409c-985c-d3ede89a25f1")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.5.1.14719")]
#endif
@@ -39,6 +39,7 @@ using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttrib
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute; using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif #endif
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities;
namespace Newtonsoft.Json.Tests.Serialization namespace Newtonsoft.Json.Tests.Serialization
{ {
@@ -42,6 +42,11 @@ using TestMethod = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttrib
#endif #endif
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Collections; using System.Collections;
#if NET20
using Newtonsoft.Json.Utilities.LinqBridge;
#else
using System.Linq;
#endif
namespace Newtonsoft.Json.Tests namespace Newtonsoft.Json.Tests
{ {
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Newtonsoft.Json
public enum DateFormatHandling public enum DateFormatHandling
{ {
/// <summary> /// <summary>
/// Dates are written in the ISO 8061 format, e.g. "2012-03-21T05:40Z". /// Dates are written in the ISO 8601 format, e.g. "2012-03-21T05:40Z".
/// </summary> /// </summary>
IsoDateFormat, IsoDateFormat,
/// <summary> /// <summary>
@@ -19,7 +19,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\Metro\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants> <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>3</WarningLevel> <WarningLevel>3</WarningLevel>
@@ -27,10 +27,11 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\Metro\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants> <DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Metro\Newtonsoft.Json.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -169,6 +170,7 @@
<Compile Include="Linq\JPath.cs" /> <Compile Include="Linq\JPath.cs" />
<Compile Include="Linq\JProperty.cs" /> <Compile Include="Linq\JProperty.cs" />
<Compile Include="Linq\JPropertyDescriptor.cs" /> <Compile Include="Linq\JPropertyDescriptor.cs" />
<Compile Include="Linq\JPropertyKeyedCollection.cs" />
<Compile Include="Linq\JRaw.cs" /> <Compile Include="Linq\JRaw.cs" />
<Compile Include="Linq\JToken.cs" /> <Compile Include="Linq\JToken.cs" />
<Compile Include="Linq\JTokenEqualityComparer.cs" /> <Compile Include="Linq\JTokenEqualityComparer.cs" />
@@ -38,6 +38,9 @@ using System.Security;
[assembly: AssemblyTitle("Json.NET Silverlight")] [assembly: AssemblyTitle("Json.NET Silverlight")]
#elif PocketPC #elif PocketPC
[assembly: AssemblyTitle("Json.NET Compact")] [assembly: AssemblyTitle("Json.NET Compact")]
#elif NETFX_CORE
[assembly: AssemblyTitle("Json.NET Metro")]
[assembly: AllowPartiallyTrustedCallers]
#elif NET20 #elif NET20
[assembly: AssemblyTitle("Json.NET .NET 2.0")] [assembly: AssemblyTitle("Json.NET .NET 2.0")]
[assembly: AllowPartiallyTrustedCallers] [assembly: AllowPartiallyTrustedCallers]
@@ -83,9 +86,9 @@ using System.Security;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("4.0.8.0")] [assembly: AssemblyVersion("4.5.0.0")]
#if !PocketPC #if !PocketPC
[assembly: AssemblyFileVersion("4.0.8.14731")] [assembly: AssemblyFileVersion("4.5.1.14719")]
#endif #endif
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]
+7 -1
View File
@@ -14,9 +14,15 @@ namespace Newtonsoft.Json
/// </summary> /// </summary>
/// <param name="assemblyName">Specifies the <see cref="Assembly"/> name of the serialized object.</param> /// <param name="assemblyName">Specifies the <see cref="Assembly"/> name of the serialized object.</param>
/// <param name="typeName">Specifies the <see cref="Type"/> name of the serialized object</param> /// <param name="typeName">Specifies the <see cref="Type"/> name of the serialized object</param>
/// <returns></returns> /// <returns>The type of the object the formatter creates a new instance of.</returns>
public abstract Type BindToType(string assemblyName, string typeName); public abstract Type BindToType(string assemblyName, string typeName);
/// <summary>
/// When overridden in a derived class, controls the binding of a serialized object to a type.
/// </summary>
/// <param name="serializedType">The type of the object the formatter creates a new instance of.</param>
/// <param name="assemblyName">Specifies the <see cref="Assembly"/> name of the serialized object.</param>
/// <param name="typeName">Specifies the <see cref="Type"/> name of the serialized object.</param>
public virtual void BindToName(Type serializedType, out string assemblyName, out string typeName) public virtual void BindToName(Type serializedType, out string assemblyName, out string typeName)
{ {
assemblyName = null; assemblyName = null;
@@ -18,14 +18,14 @@ namespace Newtonsoft.Json.Utilities
new IDictionaryEnumerator GetEnumerator(); new IDictionaryEnumerator GetEnumerator();
} }
public interface IDictionaryEnumerator : IEnumerator internal interface IDictionaryEnumerator : IEnumerator
{ {
DictionaryEntry Entry { get; } DictionaryEntry Entry { get; }
object Key { get; } object Key { get; }
object Value { get; } object Value { get; }
} }
public struct DictionaryEntry internal struct DictionaryEntry
{ {
private readonly object _key; private readonly object _key;
private readonly object _value; private readonly object _value;