FlowCommunications/JSONPath

Unable to search keys containing '-' character : solution

IntelliDust opened this issue · 2 comments

For example:

$result = (new JSONPath($data))->find('$..neighbor[?(@.neighbor-id == "192.168.1.1")]');

ends with:
PHP Fatal error: Uncaught Exception: Malformed filter query

after I replaced in QueryMatchFilter

@(\.(?<key>\w+)|\[["\']?(?<keySquare>.*?)["\']?\])
by
@(\.(?<key>\S+)|\[["\']?(?<keySquare>.*?)["\']?\])

Working like charm

This also works for me to allow searching fields with periods (.) in them, thanks!

This project is now marked as abandoned and suggests using softcreatr/jsonpath as a replacement. If you think this issue is still relevant please open a new ticket under the new project.

https://github.com/SoftCreatR/JSONPath