-Added ObjectCreationHandling to JsonPropertyAttribute

-Added IValueProvider, ReflectionValueProvider, DynamicValueProvider
-Added Dynamic.snk
-Added Required enum with options Default, AllowNull and Always
-Added serialization event support to Silverlight version
-Added Converter to JsonProperty for JsonConverter
-Changed IsRequired to Required enum
-Changed schema generator to allow for Required enum options
-Changed Silverlight project version to Silverlight 3
-Improved error message when JSON array encountered for object and vice-versa when deserializing
-Improved error message for converting types when deserializing
-Improved error message from getting and setting properties when serializing and deserializing
-Fixed empty string being converted to null when deserializing
-Removed dependency on Entity Framework and LINQ to SQL assemblies
This commit is contained in:
JamesNK
2009-11-02 08:21:02 +00:00
parent b4b3905714
commit 2a63ea24e3
51 changed files with 1466 additions and 260 deletions
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Newtonsoft.Json.Tests.TestObjects
{
public class Car
{
// included in JSON
public string Model { get; set; }
public DateTime Year { get; set; }
public List<string> Features { get; set; }
// ignored
[JsonIgnore]
public DateTime LastModified { get; set; }
}
}
@@ -32,7 +32,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
{
public class CircularReferenceClass
{
[JsonProperty(IsRequired = true)]
[JsonProperty(Required = Required.Always)]
public string Name { get; set; }
public CircularReferenceClass Child { get; set; }
}
@@ -33,7 +33,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
[JsonObject(Id = "MyExplicitId")]
public class CircularReferenceWithIdClass
{
[JsonProperty(IsRequired = true)]
[JsonProperty(Required = Required.AllowNull)]
public string Name { get; set; }
public CircularReferenceWithIdClass Child { get; set; }
}
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace Newtonsoft.Json.Tests.TestObjects
{
[DataContract]
public class Computer
{
// included in JSON
[DataMember]
public string Name { get; set; }
[DataMember]
public decimal SalePrice { get; set; }
// ignored
public string Manufacture { get; set; }
public int StockCount { get; set; }
public decimal WholeSalePrice { get; set; }
public DateTime NextShipmentDate { get; set; }
}
}
@@ -32,9 +32,16 @@ namespace Newtonsoft.Json.Tests.TestObjects
{
public string Company { get; set; }
public decimal Amount { get; set; }
[DefaultValue(false)]
// false is default value of bool
public bool Paid { get; set; }
[DefaultValue(null)]
// null is default value of nullable
public DateTime? PaidDate { get; set; }
// customize default values
[DefaultValue(30)]
public int FollowUpDays { get; set; }
[DefaultValue("")]
public string FollowUpEmailAddress { get; set; }
}
}
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Newtonsoft.Json.Tests.TestObjects
{
public class Movie
{
public string Name { get; set; }
public string Description { get; set; }
public string Classification { get; set; }
public string Studio { get; set; }
public DateTime? ReleaseDate { get; set; }
public List<string> ReleaseCountries { get; set; }
}
}
@@ -32,16 +32,16 @@ namespace Newtonsoft.Json.Tests.TestObjects
{
public class RequiredMembersClass
{
[JsonProperty(IsRequired = true)]
[JsonProperty(Required = Required.Always)]
public string FirstName { get; set; }
[JsonProperty]
public string MiddleName { get; set; }
[JsonProperty(IsRequired = true)]
[JsonProperty(Required = Required.AllowNull)]
public string LastName { get; set; }
[JsonProperty(IsRequired = true)]
[JsonProperty(Required = Required.Default)]
public DateTime BirthDate { get; set; }
}
}
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT
#if !PocketPC
using System.Collections.Generic;
using System.Runtime.Serialization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT
#if !PocketPC
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json.Tests.Serialization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT && !NET20
#if !PocketPC && !NET20
using System;
using System.Linq;
using System.Runtime.Serialization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT
#if !PocketPC
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json.Serialization;
@@ -37,9 +37,11 @@ namespace Newtonsoft.Json.Tests.TestObjects
public int[] RoomsPerFloor = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
public bool Open = false;
public char Symbol = '@';
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> Mottos = new List<string>();
public decimal Cost = 100980.1M;
public string Escape = "\r\n\t\f\b?{\\r\\n\"\'";
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<Product> product = new List<Product>();
public Store()