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

Fix logic of parsing function with no arguments. #990

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

q2w
Copy link

@q2w q2w commented Jan 21, 2024

Currently a function with no arguments is not parsed correctly. Given $.objects.keys().size(), after encountering keys (a function with no arguments) the position should move from $.objects.keys().size() to $.objects.keys().size(). But in current implementation read position moves from $.objects.keys().size() to $.objects.keys().size()

This pull request will fix the issue.

Currently a function parameter with no arguments is not parsed correctly. Given `$.objects.keys().size()`, after encountering keys (a function with no arguments) the position should move from $.objects.keys`(`).size() to $.objects.keys()`.`size(). But in current implementation read position moves from $.objects.keys`(`).size() to $.objects.keys(`)`.size()

This pull request will fix this issue.
@q2w q2w marked this pull request as ready for review January 21, 2024 16:33
@q2w
Copy link
Author

q2w commented Jan 23, 2024

@kallestenflo

@kallestenflo
Copy link
Contributor

Please provide a test in your PR that demonstrates a case.

@q2w
Copy link
Author

q2w commented Jan 29, 2024

@kallestenflo Thanks! I have added a test case for the same.

Json:

"{\"empty\": [], \"number-series\" : [[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12]]}"

JsonPath: "$.number-series.first().last()"

Before this change, the test case is failing with below error.

Expected to find an object with property [')'] in path $['number-series'] but found 'net.minidev.json.JSONArray'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
com.jayway.jsonpath.PathNotFoundException: Expected to find an object with property [')'] in path $['number-series'] but found 'net.minidev.json.JSONArray'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.

@q2w
Copy link
Author

q2w commented Feb 5, 2024

@kallestenflo

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