public void JmesPathEqualOperator_Evaluate()
        {
            JmesPathExpression expression = new JmesPathFilterProjection(
                new JmesPathEqualOperator(
                    new JmesPathIdentifier("bar"),
                    new JmesPathLiteral(10)
                    )
                );

            Assert(expression, "[{\"bar\": 1}, {\"bar\": 10}]", "[{\"bar\":10}]");

            expression = new JmesPathIndexExpression(
                new JmesPathIdentifier("foo"),
                expression
                );

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

            expression = new JmesPathIndexExpression(
                new JmesPathIdentifier("foo"),
                new JmesPathFilterProjection(
                    new JmesPathEqualOperator(
                        new JmesPathIdentifier("a"),
                        new JmesPathIdentifier("b")
                        )
                    )
                );

            Assert(expression, "{\"foo\": [{\"a\": 1, \"b\": 2}, {\"a\": 2, \"b\": 2}]}", "[{\"a\":2,\"b\":2}]");
        }
Exemple #2
0
        public void OnFilterProjection()
        {
            Prolog();

            System.Diagnostics.Debug.Assert(expressions_.Count >= 1);

            var comparison = expressions_.Pop();
            var expression = new JmesPathFilterProjection(comparison);

            expressions_.Push(expression);
        }
        public void JmesPathGreaterThanOperator_Evaluate_date_as_strings()
        {
            const string json     = "[{\"a\": \"2018-01-01T00:00:00.000Z\"}, {\"a\": \"2018-02-01T00:00:00.000Z\"}, {\"a\": \"2018-03-01T00:00:00.000Z\"}]";
            const string expected = "[{\"a\":\"2018-02-01T00:00:00.000Z\"},{\"a\":\"2018-03-01T00:00:00.000Z\"}]";

            var expression = new JmesPathFilterProjection(
                new JmesPathGreaterThanOperator(
                    new JmesPathIdentifier("a"),
                    new JmesPathLiteral("2018-01-01T14:27:34.999Z")
                    )
                );

            Assert(expression, json, expected);
        }
        public void JmesPathGreaterThanOperator_Evaluate()
        {
            const string json     = "[{\"a\": 1}, {\"a\": 2}, {\"a\": 3}]";
            const string expected = "[{\"a\":2},{\"a\":3}]";

            var expression = new JmesPathFilterProjection(
                new JmesPathGreaterThanOperator(
                    new JmesPathIdentifier("a"),
                    new JmesPathLiteral(1)
                    )
                );

            Assert(expression, json, expected);
        }