Skip to content

Adding ability to define Functions#354

Open
rmcraig1978 wants to merge 2 commits intojson-path:masterfrom
rmcraig1978:master
Open

Adding ability to define Functions#354
rmcraig1978 wants to merge 2 commits intojson-path:masterfrom
rmcraig1978:master

Conversation

@rmcraig1978
Copy link
Copy Markdown

Using the configuration object to contains dynamic Function definition.

@jochenberger
Copy link
Copy Markdown
Contributor

See also #286 for an alternate solution

@ghost
Copy link
Copy Markdown

ghost commented Oct 25, 2018

Nice Feature ,
you should take care about something there is bug into FilterCompiler.class.
into this function
private boolean currentCharIsClosingFunctionBracket(int lowerBound){
if(filter.currentChar() != CLOSE_PARENTHESIS){
return false;
}
int idx = filter.indexOfPreviousSignificantChar();
if(idx == -1 || filter.charAt(idx) != OPEN_PARENTHESIS){
return false;
}
idx--;
while(filter.inBounds(idx) && idx > lowerBound){
if(filter.charAt(idx) == PERIOD){
return true;
}
idx--;
}
return false;
}

if you use function with argument into filter the token ')' will be miss
for example $.store[?(@.book.yourFunction(1))] will compile @.book.yourFunction(1
end bracket is missing because this condition will match ---> if(idx == -1 || filter.charAt(idx) != OPEN_PARENTHESIS

@cristph
Copy link
Copy Markdown

cristph commented Jan 21, 2022

why gave up this PR halfway?
it's a very nice feature

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.

4 participants