-Fix bug when JValue of type string has a null string value
-Fix JToken casting bugs to float and decimal
This commit is contained in:
@@ -410,5 +410,23 @@ Parameter name: arrayIndex")]
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteObjectNullStringValue()
|
||||
{
|
||||
string s = null;
|
||||
JValue v = new JValue(s);
|
||||
Assert.AreEqual(null, v.Value);
|
||||
Assert.AreEqual(JTokenType.String, v.Type);
|
||||
|
||||
JObject o = new JObject();
|
||||
o["title"] = v;
|
||||
|
||||
string output = o.ToString();
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""title"": null
|
||||
}", output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,6 +235,11 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Assert.AreEqual(ulong.MaxValue, (ulong)new JValue(ulong.MaxValue));
|
||||
Assert.AreEqual(ulong.MaxValue, (ulong)new JProperty("Test", new JValue(ulong.MaxValue)));
|
||||
Assert.AreEqual(null, (string)new JValue((string)null));
|
||||
Assert.AreEqual(5m, (decimal)(new JValue(5L)));
|
||||
Assert.AreEqual(5m, (decimal?)(new JValue(5L)));
|
||||
Assert.AreEqual(5f, (float)(new JValue(5L)));
|
||||
Assert.AreEqual(5f, (float)(new JValue(5m)));
|
||||
Assert.AreEqual(5f, (float?)(new JValue(5m)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user