Skip to content

Restore pre-8.0 behavior regarding array returned by jsonpath #5077

@fubar-coder

Description

@fubar-coder

Problem to solve

I want to test whether - for example - jsonpath "$.emails[?(@.subject=='expected subject')].receivers" returns 2 receivers in the first occurrence of the array element containing expected subject` as subject.

This test has become impossible since 8.0, as there is now a "convenience" functionality that implicitly replaces an array with a single element with the single element itself, which breaks all scripts that rely on first.

Proposal

There are several solutions:

  • Restore the 7.x behavior
  • Restore the 7.x behavior when a option is passed to hurl
  • Allow first to accept objects or scalar values

Additional context and resources

Currently, I have no workaround for my use case. The exists predicate doesn't support my use case.

My original assertion was:

jsonpath "$.emails[?(@.subject=='expected subject')].receivers" first count == 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions