Пример #1
0
        public void OnIndex(int index)
        {
            Prolog();

            var expression = new JmesPathIndex(index);

            expressions_.Push(expression);
        }
        public void JmesPathProjection_Wildcard_List()
        {
            JmesPathExpression identifier = new JmesPathIdentifier("foo");
            JmesPathProjection wildcard   = new JmesPathListWildcardProjection();
            JmesPathExpression expression = new JmesPathSubExpression(wildcard, identifier);

            Assert(expression, "[{\"foo\": 1}, {\"foo\": 2}, {\"foo\": 3}]", "[1,2,3]");
            Assert(expression, "[{\"foo\": 1}, {\"foo\": 2}, {\"bar\": 3}]", "[1,2]");

            identifier = new JmesPathIndex(0);
            wildcard   = new JmesPathListWildcardProjection();
            expression = new JmesPathIndexExpression(wildcard, identifier);

            Assert(expression, "[\"foo\", \"bar\"]", "[]");
        }
Пример #3
0
        private void OnIndex(Token token)
        {
            Prolog();

            var number = token as NumberToken;

            System.Diagnostics.Debug.Assert(token.Type == TokenType.T_NUMBER);
            System.Diagnostics.Debug.Assert(number != null);

            var index = (int)number.Value;

            var expression = new JmesPathIndex(index);

            expressions_.Push(expression);
        }