public void JmesPathProjection_Slice() { // expression foo[0:2].a JmesPathExpression expression = new JmesPathSubExpression( new JmesPathIndexExpression( new JmesPathIdentifier("foo"), new JmesPathSliceProjection(0, 2, null) ), new JmesPathIdentifier("a") ); Assert(expression, "{\"foo\": [{\"a\": 1}, {\"a\": 2}, {\"a\": 3}, {\"a\": 4}]}", "[1,2]"); // expression foo[0:2][0:1] expression = new JmesPathIndexExpression( new JmesPathIndexExpression( new JmesPathIdentifier("foo"), new JmesPathSliceProjection(0, 2, null) ), new JmesPathSliceProjection(0, 1, null) ); Assert(expression, "{\"foo\": [[1, 2, 3], [4, 5, 6]]}", "[[1],[4]]"); }
public void JmesPathProjection_Wildcard_Hash() { var expression = new JmesPathSubExpression( new JmesPathHashWildcardProjection(), new JmesPathIdentifier("foo") ); Assert(expression, "{\"a\": {\"foo\": 1}, \"b\": {\"foo\": 2}, \"c\": {\"bar\": 1}}", "[1,2]"); }
public void OnSubExpression() { Prolog(); System.Diagnostics.Debug.Assert(expressions_.Count >= 2); var right = expressions_.Pop(); var left = expressions_.Pop(); var expression = new JmesPathSubExpression(left, right); 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\"]", "[]"); }