-Fixed error when writing JSON for a JProperty with no value

-LINQ to JSON performance improvements
This commit is contained in:
James Newton-King
2012-08-11 20:12:49 +12:00
parent 7359433dc7
commit f5fec30c2a
6 changed files with 78 additions and 29 deletions
+8 -3
View File
@@ -65,14 +65,14 @@ namespace Newtonsoft.Json.Linq
public JToken Value
{
[DebuggerStepThrough]
get { return (ChildrenTokens.Count > 0) ? ChildrenTokens[0] : null; }
get { return (_content.Count > 0) ? _content[0] : null; }
set
{
CheckReentrancy();
JToken newValue = value ?? new JValue((object) null);
if (ChildrenTokens.Count == 0)
if (_content.Count == 0)
{
InsertItem(0, newValue, false);
}
@@ -209,7 +209,12 @@ namespace Newtonsoft.Json.Linq
public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
{
writer.WritePropertyName(_name);
Value.WriteTo(writer, converters);
JToken value = Value;
if (value != null)
value.WriteTo(writer, converters);
else
writer.WriteNull();
}
internal override int GetDeepHashCode()