public void OnExpression() { if (expression_ == null) { expression_ = expressions_.Pop(); } }
public JmesPathFunctionArgument(JmesPathExpression expression) { System.Diagnostics.Debug.Assert(expression.IsExpressionType); token_ = null; expression_ = expression; }
private void OnExpression() { if (expression_ == null) { expression_ = expressions_.Pop(); } }
public JmesPathFunctionArgument(JToken token) { System.Diagnostics.Debug.Assert(token != null); token_ = token; expression_ = null; }
protected virtual void Assert(JmesPathExpression expression, string input, string expected) { var json = JmesPath.ParseJson(input); var result = expression.Transform(json); var actual = result.AsJToken().AsString(); Xunit.Assert.Equal(expected, actual); }
public void OnExpressionType() { Prolog(); var expression = expressions_.Pop(); JmesPathExpression.MakeExpressionType(expression); expressions_.Push(expression); }
public void Visit(JmesPathExpression expression) { var projection = expression as JmesPathSliceProjection; if (projection?.Step != null && projection.Step.Value == 0) { throw new Exception("Error: invalid-value, a slice projection step cannot be 0."); } }
bool Prolog() { if (expression_ != null) { expressions_.Push(expression_); expression_ = null; return(true); } return(false); }
private void Assert(string[] expressions, string input, string expected) { JmesPathExpression expression = null; foreach (var identifier in expressions) { JmesPathExpression ident = new JmesPathIdentifier(identifier); expression = expression != null ? new JmesPathSubExpression(expression, ident) : ident ; } Assert(expression, input, expected); }
protected JToken Evaluate(JmesPathExpression expression, JToken token) { var eval = expression.Transform(token).AsJToken(); var type = eval.GetTokenType(); if (type != "number" && type != "string") { throw new Exception($"Error: invalid-type, the expression argument of function {Name} should return a number or a string."); } if (type == "number") { return(eval); } double number; if (double.TryParse(eval.Value <string>(), out number)) { return(new JValue(number)); } throw new Exception("Error: invalid-type, when evaluating the expression argument of function {Name}, some items could not be cast to a number."); }
internal Expression(JmesPathExpression expression) { expression_ = expression; }
protected override JmesPathExpression CreateWith(JmesPathExpression left, JmesPathExpression right) => new JmesPathGreaterThanOrEqualOperator(left, right);
/// <summary> /// Initialize a new instance of the <see cref="JmesPathGreaterThanOrEqualOperator"/> class /// to perform a comparison between two specified expressions. /// </summary> /// <param name="left"></param> /// <param name="right"></param> public JmesPathGreaterThanOrEqualOperator(JmesPathExpression left, JmesPathExpression right) : base(left, right) { }
/// <summary> /// Initialize a new instance of the <see cref="JmesPathLessThanOperator"/> class /// to perform a comparison between two specified expressions. /// </summary> /// <param name="left"></param> /// <param name="right"></param> public JmesPathLessThanOperator(JmesPathExpression left, JmesPathExpression right) : base(left, right) { }
internal Expression(JmesPathExpression expression) { InnerExpression = expression; }