Skip to content

Commit

Permalink
Support Count, Length on json paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Dec 13, 2011
1 parent ee108c1 commit c6f8f61
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Raven.Abstractions/Json/Linq/RavenJPath.cs
Expand Up @@ -129,6 +129,24 @@ internal RavenJToken Evaluate(RavenJToken root, bool errorWhenNoMatch)
}
else
{
var array = current as RavenJArray;
if(array != null)
{
switch (propertyName)
{
case "Count":
case "count":
case "Length":
case "length":
current = array.Length;
break;
default:
if (errorWhenNoMatch)
throw new Exception("Property '{0}' not valid on {1}.".FormatWith(CultureInfo.InvariantCulture, propertyName, current.GetType().Name));
break;
}
continue;
}
if (errorWhenNoMatch)
throw new Exception("Property '{0}' not valid on {1}.".FormatWith(CultureInfo.InvariantCulture, propertyName, current.GetType().Name));

Expand Down

0 comments on commit c6f8f61

Please sign in to comment.