Skip to content

Conversation

gongfarmer
Copy link
Contributor

Add test slice selector followed by slice selector
Add test filter selector followed by child segment that selects multiple elements
Add test filter selector followed by name selector

],
"result": [ 1, null ],
"result_paths": [
"$['a']['x']",
Copy link
Collaborator

@f3ath f3ath Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one does not seem right. The root element of the document is an array, so any path must start with $[0].

Copy link
Contributor Author

@gongfarmer gongfarmer Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$[0] would select the first array element, which is the hash. This is not what is wanted here - the filter selector is supposed to be applied to the array, not the hash.

For comparison, see the other tests within filter.json.

     5       "selector": "$[? @.a]",
    31       "selector": "$[?\n@.a]",
    57       "selector": "$[?\t@.a]",
    83       "selector": "$[?\r@.a]",
 ...

In every test, the document is an array, and the filter selector is applied directly to the root identifer.

Maybe it's confusing that I only put one element in the array, so there's nothing to show what is not being selected by the filter. Would it help to add another array element?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root element of the document in this test is an array with a single element:

       [
        {
          "a": { "x": 1, "y": null, "z": "_" }
        }
      ]

therefore anything in the "result_paths" has to start with an array index: $[0], but the result paths provided start with $['a'] as if the root element was an object. Does the document have extra square brackets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, you were referring to the result_paths, which is exactly what your comment is on. I should have seen that.

Yes I agree. I'll correct that and re-test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed an updated version.

I corrected the paths and changed the document for this test, which did not match the selector.
(The { "a": ... } hash should not have been there, only the single value it contains.)

Copy link
Collaborator

@f3ath f3ath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "followed by child segment that selects multiple elements" seems off.

@gongfarmer
Copy link
Contributor Author

The "followed by child segment that selects multiple elements" seems off.

It's named that way because when cts.json is built, this name is appended onto the name of the file.
So within cts.json the test is named "filter, followed by child segment that selects multiple elements"

Is that the issue?

@f3ath
Copy link
Collaborator

f3ath commented Feb 11, 2025

The "followed by child segment that selects multiple elements" seems off.

It's named that way because when cts.json is built, this name is appended onto the name of the file. So within cts.json the test is named "filter, followed by child segment that selects multiple elements"

Is that the issue?

Sorry, I didn't mean the name itself. See the comment here: #102 (comment)

@gongfarmer gongfarmer force-pushed the 96-filter-followed-by-name-selector branch from 346584e to d88c87c Compare February 11, 2025 17:49
Copy link
Collaborator

@f3ath f3ath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@f3ath f3ath requested a review from gregsdennis February 12, 2025 01:06
@f3ath
Copy link
Collaborator

f3ath commented Feb 12, 2025

Passes on my implementation. @gregsdennis can you please check on your end?

@f3ath f3ath merged commit 509e460 into jsonpath-standard:main Feb 17, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants