h2non/jsonpath-ng

Error when adding filter

msbarrenjoey opened this issue · 1 comments

Hi,

Trying to filter the emails but getting the below error.

Python: Python 3.7.16
jsonpath-ng: 1.6.1

email_pattern = 'emails[?(@.type == "work")].value'

{ "totalResults": 5, "itemsPerPage": 5, "startIndex": 1, "schemas": [ "urn:ietf:params:scim:api:messages:2.0:ListResponse" ], "Resources": [ { "id": "90677c608a-7afcdc23-0bd4-4fb7-b2ff-10ccffdff447", "externalId": "702135", "meta": { "resourceType": "User", "created": "2020-07-22T22:32:58Z", "lastModified": "2020-07-22T22:32:58Z" }, "schemas": [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ], "userName": "mjack", "name": { "familyName": "Mark", "givenName": "Jackson", "honorificPrefix": "Mr.", "honorificSuffix": "I" }, "displayName": "mjack", "nickName": "Mark", "active": False, "emails": [ { "value": "mjack@example.com", "type": "work", "primary": True } ], "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "manager": { "value": "9067729b3d-ee533c18-538a-4cd3-a572-63fb863ed734" } } }, { "id": "90677c608a-787142a0-3f27-4cd3-afb6-8aed7ce87094", "externalId": "705167", "meta": { "resourceType": "User", "created": "2020-07-22T22:34:55Z", "lastModified": "2020-07-22T22:34:55Z" }, "schemas": [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ], "userName": "druss", "name": { "familyName": "Daniel", "givenName": "Russell", "honorificPrefix": "Mr.", "honorificSuffix": "I" }, "displayName": "danrussell", "nickName": "Dan", "active": False, "emails": [ { "value": "druss@example.com", "type": "work", "primary": True } ], "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "manager": { "value": "9067729b3d-ee533c18-538a-4cd3-a572-63fb863ed734" } } }, { "id": "90677c608a-229f7eb1-c07d-4c21-a5fd-769bf2e8c5c9", "externalId": "2", "meta": { "resourceType": "User", "created": "2020-07-22T23:51:45Z", "lastModified": "2020-07-22T23:51:45Z" }, "schemas": [ "urn:ietf:params:scim:schemas:core:2.0:User" ], "userName": "tzhang", "name": { "familyName": "Terry", "givenName": "Zhang" }, "displayName": "Terry Zhang", "active": False, "emails": [ { "value": "tzhang@example.com", "type": "work", "primary": True } ] }, { "id": "90677c608a-685d5bf3-efab-48c8-b3b1-648fc5c5d980", "externalId": "701985", "meta": { "resourceType": "User", "created": "2020-07-22T22:17:47Z", "lastModified": "2020-07-22T22:17:47Z" }, "schemas": [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ], "userName": "jdoe", "name": { "familyName": "John", "givenName": "Doe", "honorificPrefix": "Mr.", "honorificSuffix": "III" }, "displayName": "jdoe", "nickName": "Johnny", "active": False, "emails": [ { "value": "johndoe@example.com", "type": "work", "primary": True } ], "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "manager": { "value": "9067729b3d-ee533c18-538a-4cd3-a572-63fb863ed734" } } }, { "id": "90677c608a-9683e752-a6fd-4935-b6b8-3fe26a202f21", "externalId": "702138", "meta": { "resourceType": "User", "created": "2020-07-22T22:38:11Z", "lastModified": "2020-07-22T22:38:11Z" }, "schemas": [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ], "userName": "hmack", "name": { "familyName": "Henry", "givenName": "Mackenzie", "honorificPrefix": "Mr.", "honorificSuffix": "I" }, "displayName": "hmack", "nickName": "Henry", "active": False, "emails": [ { "value": "hmack@example.com", "type": "work", "primary": True } ], "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "manager": { "value": "9067729b3d-ee533c18-538a-4cd3-a572-63fb863jd956" } } } ] }

Traceback (most recent call last): File "./domain/extractor_scim.py", line 203, in <module> query = parse(email_pattern) File "/home/stahir/.local/lib/python3.7/site-packages/jsonpath_ng/parser.py", line 15, in parse return JsonPathParser().parse(string) File "/home/stahir/.local/lib/python3.7/site-packages/jsonpath_ng/parser.py", line 38, in parse return self.parse_token_stream(lexer.tokenize(string)) File "/home/stahir/.local/lib/python3.7/site-packages/jsonpath_ng/parser.py", line 62, in parse_token_stream return new_parser.parse(lexer = IteratorToTokenStream(token_iterator)) File "/home/stahir/.local/lib/python3.7/site-packages/ply/yacc.py", line 333, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) File "/home/stahir/.local/lib/python3.7/site-packages/ply/yacc.py", line 1063, in parseopt_notrack lookahead = get_token() # Get the next token File "/home/stahir/.local/lib/python3.7/site-packages/jsonpath_ng/parser.py", line 191, in token return next(self.iterator) File "/home/stahir/.local/lib/python3.7/site-packages/jsonpath_ng/lexer.py", line 32, in tokenize t = new_lexer.token() File "/home/stahir/.local/lib/python3.7/site-packages/ply/lex.py", line 386, in token newtok = self.lexerrorf(tok) File "/home/stahir/.local/lib/python3.7/site-packages/jsonpath_ng/lexer.py", line 165, in t_error raise JsonPathLexerError('Error on line %s, col %s: Unexpected character: %s ' % (t.lexer.lineno, t.lexpos - t.lexer.latest_newline, t.value[0])) jsonpath_ng.exceptions.JsonPathLexerError: Error on line 1, col 7: Unexpected character: ?

not using the .ext.
With ext import its working fine