-Increment version to 5.0.5
This commit is contained in:
@@ -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>5.0.4</version>
|
<version>5.0.5</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>
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
properties {
|
properties {
|
||||||
$zipFileName = "Json50r4.zip"
|
$zipFileName = "Json50r5.zip"
|
||||||
$majorVersion = "4.5"
|
$majorVersion = "4.5"
|
||||||
$majorWithReleaseVersion = "5.0.4"
|
$majorWithReleaseVersion = "5.0.5"
|
||||||
$version = GetVersion $majorWithReleaseVersion
|
$version = GetVersion $majorWithReleaseVersion
|
||||||
$signAssemblies = $false
|
$signAssemblies = $false
|
||||||
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
|
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ using System.Threading.Tasks;
|
|||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
using Newtonsoft.Json.Tests.Serialization;
|
using Newtonsoft.Json.Tests.Serialization;
|
||||||
using Newtonsoft.Json.Tests.TestObjects;
|
using Newtonsoft.Json.Tests.TestObjects;
|
||||||
using Newtonsoft.Json.Utilities;
|
using Newtonsoft.Json.Utilities;
|
||||||
@@ -76,6 +77,42 @@ namespace Newtonsoft.Json.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DefaultSettings_Example()
|
||||||
|
{
|
||||||
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||||
|
};
|
||||||
|
|
||||||
|
Employee e = new Employee
|
||||||
|
{
|
||||||
|
FirstName = "Eric",
|
||||||
|
LastName = "Example",
|
||||||
|
BirthDate = new DateTime(1980, 4, 20, 0, 0, 0, DateTimeKind.Utc),
|
||||||
|
Department = "IT",
|
||||||
|
JobTitle = "Web Dude"
|
||||||
|
};
|
||||||
|
|
||||||
|
string json = JsonConvert.SerializeObject(e);
|
||||||
|
// {
|
||||||
|
// "firstName": "Eric",
|
||||||
|
// "lastName": "Example",
|
||||||
|
// "birthDate": "1980-04-20T00:00:00Z",
|
||||||
|
// "department": "IT",
|
||||||
|
// "jobTitle": "Web Dude"
|
||||||
|
// }
|
||||||
|
|
||||||
|
Assert.AreEqual(@"{
|
||||||
|
""firstName"": ""Eric"",
|
||||||
|
""lastName"": ""Example"",
|
||||||
|
""birthDate"": ""1980-04-20T00:00:00Z"",
|
||||||
|
""department"": ""IT"",
|
||||||
|
""jobTitle"": ""Web Dude""
|
||||||
|
}", json);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void DefaultSettings_Override()
|
public void DefaultSettings_Override()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -231,6 +231,18 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
public IDictionary<object, object> ExtensionData;
|
public IDictionary<object, object> ExtensionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DeserializeDirectoryAccount()
|
||||||
|
{
|
||||||
|
string json = @"{'DisplayName':'John Smith', 'SAMAccountName':'contoso\\johns'}";
|
||||||
|
|
||||||
|
DirectoryAccount account = JsonConvert.DeserializeObject<DirectoryAccount>(json);
|
||||||
|
|
||||||
|
Assert.AreEqual("John Smith", account.DisplayName);
|
||||||
|
Assert.AreEqual("contoso", account.Domain);
|
||||||
|
Assert.AreEqual("johns", account.UserName);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SerializePublicExtensionData()
|
public void SerializePublicExtensionData()
|
||||||
{
|
{
|
||||||
@@ -9314,4 +9326,28 @@ Parameter name: value",
|
|||||||
get { return FavoriteNumber != 0; }
|
get { return FavoriteNumber != 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DirectoryAccount
|
||||||
|
{
|
||||||
|
// normal deserialization
|
||||||
|
public string DisplayName { get; set; }
|
||||||
|
|
||||||
|
// these properties are set in OnDeserialized
|
||||||
|
public string UserName { get; set; }
|
||||||
|
public string Domain { get; set; }
|
||||||
|
|
||||||
|
[JsonExtensionData]
|
||||||
|
private IDictionary<string, JToken> _additionalData;
|
||||||
|
|
||||||
|
[OnDeserialized]
|
||||||
|
private void OnDeserialized(StreamingContext context)
|
||||||
|
{
|
||||||
|
// SAMAccountName is not deserialized to any property
|
||||||
|
// and so it is added to the extension data dictionary
|
||||||
|
string samAccountName = (string)_additionalData["SAMAccountName"];
|
||||||
|
|
||||||
|
Domain = samAccountName.Split('\\')[0];
|
||||||
|
UserName = samAccountName.Split('\\')[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user