-Fixed error with whitespace only JSONPath

-Fixed property query path that starts with $
-Fixed array query path with open brace after $
This commit is contained in:
James Newton-King
2014-02-23 14:35:28 +13:00
parent c49b58ae18
commit e4ae07003b
4 changed files with 62 additions and 14 deletions
+13 -10
View File
@@ -51,21 +51,24 @@ namespace Newtonsoft.Json.Linq.JsonPath
{
int currentPartStartIndex = _currentIndex;
if (_expression.Length == 0)
return;
EatWhitespace();
if (_expression.Length == _currentIndex)
return;
if (_expression[_currentIndex] == '$')
{
_currentIndex++;
if (_expression.Length == 1)
return;
EnsureLength("Unexpected end while parsing path.");
if (_expression[_currentIndex] != '.')
throw new JsonException("Unexpected character while parsing path: " + _expression[_currentIndex]);
currentPartStartIndex = _currentIndex;
// only increment position for "$." or "$["
// otherwise assume property that starts with $
char c = _expression[_currentIndex + 1];
if (c == '.' || c == '[')
{
_currentIndex++;
currentPartStartIndex = _currentIndex;
}
}
if (!ParsePath(Filters, currentPartStartIndex, false))