Skip to content

JmesPath : invalid result, maybe related to projection #12

Open
@L3Z4

Description

@L3Z4

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions