Exemple #1
0
        public void PopMultiSelectHash()
        {
            System.Diagnostics.Debug.Assert(selectHashes_.Count > 0);
            var items      = selectHashes_.Pop();
            var expression = new JmesPathMultiSelectHash(items);

            expressions_.Push(expression);
        }
Exemple #2
0
        public void JmesPathMultiSelectHash()
        {
            JmesPathMultiSelectHash expression = new JmesPathMultiSelectHash(
                new Dictionary <string, JmesPathExpression>
            {
                { "foo", new JmesPathIdentifier("foo") },
                { "bar", new JmesPathIdentifier("bar") },
            }
                );

            Assert(expression, "{\"foo\": \"a\", \"bar\": \"b\", \"baz\": \"c\"}", "{\"foo\":\"a\",\"bar\":\"b\"}");
            Assert(expression, "{\"foo\": \"a\", \"baz\": \"b\"}", "{\"foo\":\"a\",\"bar\":null}");

            expression = new JmesPathMultiSelectHash(
                new Dictionary <string, JmesPathExpression>
            {
                { "foo", new JmesPathIdentifier("foo") },
                {
                    "bar.baz", new JmesPathSubExpression(
                        new JmesPathIdentifier("bar"),
                        new JmesPathIdentifier("baz"))
                },
            }
                );

            Assert(expression, "{\"foo\": \"a\", \"bar\": {\"baz\": \"b\"}}", "{\"foo\":\"a\",\"bar.baz\":\"b\"}");

            expression = new JmesPathMultiSelectHash(
                new Dictionary <string, JmesPathExpression>
            {
                { "foo", new JmesPathIdentifier("foo") },
                {
                    "firstbar", new JmesPathIndexExpression(
                        new JmesPathIdentifier("bar"),
                        new JmesPathIndex(0))
                },
            }
                );

            Assert(expression, "{\"foo\": \"a\", \"bar\": [\"b\"]}", "{\"foo\":\"a\",\"firstbar\":\"b\"}");
        }