-Fixed jsonpath error when parsing a property that follows an escaped property

-Changed reader/writer/token path to escape property names containing special characters
This commit is contained in:
James Newton-King
2014-10-18 15:36:42 +13:00
parent 01f1c5e261
commit 88a29704da
12 changed files with 385 additions and 287 deletions
+4 -10
View File
@@ -188,7 +188,7 @@ namespace Newtonsoft.Json.Linq
IList<JToken> ancestors = Ancestors().Reverse().ToList();
ancestors.Add(this);
StringBuilder sb = new StringBuilder();
IList<JsonPosition> positions = new List<JsonPosition>();
for (int i = 0; i < ancestors.Count; i++)
{
JToken current = ancestors[i];
@@ -204,25 +204,19 @@ namespace Newtonsoft.Json.Linq
{
case JTokenType.Property:
JProperty property = (JProperty)current;
if (sb.Length > 0)
sb.Append('.');
sb.Append(property.Name);
positions.Add(new JsonPosition(JsonContainerType.Object) { PropertyName = property.Name });
break;
case JTokenType.Array:
case JTokenType.Constructor:
int index = ((IList<JToken>)current).IndexOf(next);
sb.Append('[');
sb.Append(index);
sb.Append(']');
positions.Add(new JsonPosition(JsonContainerType.Array) { Position = index });
break;
}
}
}
return sb.ToString();
return JsonPosition.BuildPath(positions);
}
}