Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JmesPath : invalid result, maybe related to projection #12

Open
L3Z4 opened this issue Jan 6, 2025 · 0 comments
Open

JmesPath : invalid result, maybe related to projection #12

L3Z4 opened this issue Jan 6, 2025 · 0 comments

Comments

@L3Z4
Copy link

L3Z4 commented Jan 6, 2025

I'm trying to apply this expression to the following document

length((components[?type == 'Stepper'].children | @[].validationState)[?@ == 'NotValid']) == `0`
{
  "components": [
    {
      "type": "Stepper",
      "children": [
        {
          "validationState": "NotValid"
        },
        {
          "validationState": "Valid"
        }
      ]
    }
  ]
}

The expected result should be "false", as it is the actual value returned by the online tester https://jmespath.org/.

var text = File.ReadAllText(Path.Combine("test_files", "projection_issue.json"));
var jsonOptions = new JsonDocumentOptions();
jsonOptions.CommentHandling = JsonCommentHandling.Skip;
using JsonDocument doc = JsonDocument.Parse(text, jsonOptions);

var expression = JsonTransformer.Parse("length((components[?type == 'Stepper'].children | @[].validationState)[?@ == 'NotValid']) == `0`");
var result = expression.Transform(doc.RootElement);
Assert.IsFalse(result.RootElement.GetBoolean());

This unit test is currently failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant