public JmesPathExpressionEvaluator(JmesPath jmesPath, string expression) { EnsureArg.IsNotNull(jmesPath, nameof(jmesPath)); EnsureArg.IsNotNullOrWhiteSpace(expression, nameof(expression)); try { _jmespathExpression = jmesPath.Parse(expression); } catch (Exception e) { throw new TemplateExpressionException($"The following JmesPath expression could not be parsed: {expression}", e); } }
public void InsertString_AtEnd_Succeeds(string original, string toInsert, string expected) { var data = JObject.FromObject(new { original = original, toInsert = toInsert, }); _expression = _jmesPath.Parse("insertString(original, toInsert, length(original))"); var jmesArgument = _expression.Transform(data); Assert.Equal(JTokenType.String, jmesArgument.Token.Type); Assert.Equal(expected, jmesArgument.Token.Value <string>()); }
public AddFunctionTests() { _jmesPath = new JmesPath(); _jmesPath.FunctionRepository.Register <AddFunction>(); _expression = _jmesPath.Parse("add(left, right)"); }
public SubtractFunctionTests() { _jmesPath = new JmesPath(); _jmesPath.FunctionRepository.Register <SubtractFunction>(); _expression = _jmesPath.Parse("subtract(left, right)"); }
public InsertStringFunctionTests() { _jmesPath = new JmesPath(); _jmesPath.FunctionRepository.Register <InsertStringFunction>(); _expression = _jmesPath.Parse("insertString(original, toInsert, pos)"); }
public MultiplyFunctionTests() { _jmesPath = new JmesPath(); _jmesPath.FunctionRepository.Register <MultiplyFunction>(); _expression = _jmesPath.Parse("multiply(left, right)"); }
public FromUnixTimestampMillisecondsTests() { _jmesPath = new JmesPath(); _jmesPath.FunctionRepository.Register <FromUnixTimestampFunctionMilliseconds>(); _expression = _jmesPath.Parse("fromUnixTimestampMs(timestamp)"); }
public PowerFunctionTests() { _jmesPath = new JmesPath(); _jmesPath.FunctionRepository.Register <PowerFunction>(); _expression = _jmesPath.Parse("pow(left, right)"); }
public DivideFunctionTests() { _jmesPath = new JmesPath(); _jmesPath.FunctionRepository.Register <DivideFunction>(); _expression = _jmesPath.Parse("divide(left, right)"); }