diff options
author | JamesNK <james@newtonking.com> | 2011-08-01 09:42:05 +0400 |
---|---|---|
committer | JamesNK <james@newtonking.com> | 2011-08-01 09:42:05 +0400 |
commit | e65e371e1d5ce94ad188cce7e483fcb1ede5cca2 (patch) | |
tree | 5379ea82f37715a8c91ad7f9dc88831687ed8dd3 /Src/Newtonsoft.Json.Tests | |
parent | bc726f1b6de78a4455b588865e328184afd7ed9a (diff) |
-Changed $id and $ref properties to allow null
Diffstat (limited to 'Src/Newtonsoft.Json.Tests')
-rw-r--r-- | Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs | 2 | ||||
-rw-r--r-- | Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs | 23 |
2 files changed, 23 insertions, 2 deletions
diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs index 3e6d327..44cd749 100644 --- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs @@ -41,5 +41,5 @@ using System.Runtime.InteropServices; // by using the '*' as shown below:
[assembly: AssemblyVersion("4.0.2.0")]
#if !PocketPC
-[assembly: AssemblyFileVersion("4.0.2.13928")]
+[assembly: AssemblyFileVersion("4.0.2.14001")]
#endif
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index 3d03c08..3bc15e6 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -3272,7 +3272,7 @@ keyword such as type of business."" }
[Test]
- [ExpectedException(typeof(JsonSerializationException), ExpectedMessage = "JSON reference $ref property must have a string value.")]
+ [ExpectedException(typeof(JsonSerializationException), ExpectedMessage = "JSON reference $ref property must have a string or null value.")]
public void SerializeRefBadType()
{
//Additional text found in JSON string after finishing deserializing object.
@@ -3290,6 +3290,27 @@ keyword such as type of business."" JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
}
+ [Test]
+ public void SerializeRefNull()
+ {
+ var reference = new Dictionary<string, object>();
+ reference.Add("$ref", null);
+ reference.Add("$id", null);
+ reference.Add("blah", "blah!");
+
+ var child = new Dictionary<string, object>();
+ child.Add("_id", 2);
+ child.Add("Name", "Isabell");
+ child.Add("Father", reference);
+
+ var json = JsonConvert.SerializeObject(child);
+ Dictionary<string, object> result = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
+
+ Assert.AreEqual(3, result.Count);
+ Assert.AreEqual(1, ((JObject) result["Father"]).Count);
+ Assert.AreEqual("blah!", (string)((JObject)result["Father"])["blah"]);
+ }
+
public class ConstructorCompexIgnoredProperty
{
[JsonIgnore]
|