GypsyKing25
GypsyKing25

Reputation: 3

Jsonpath error when making a filter query - 'Parse error at %s:%s near token %s (%s)'

So after running the following test code:

from jsonpath_ng import parse
import json

dici = """
{
    "store": {
        "book": [
            {
                "category": "reference",
                "author": "Nigel Rees",
                "title": "Sayings of the Century",
                "price": 8.95
            },
            {
                "category": "fiction",
                "author": "Herman Melville",
                "title": "Moby Dick",
                "isbn": "0-553-21311-3",
                "price": 8.99
            },
            {
                "category": "fiction",
                "author": "J.R.R. Tolkien",
                "title": "The Lord of the Rings",
                "isbn": "0-395-19395-8",
                "price": 22.99
            }
        ],
        "bicycle": {
            "color": "red",
            "price": 19.95
        }
    },
    "expensive": 10
}
"""

jayson = json.loads(dici)
a = [match.value for match in parse('$..book[?(@.price < 10)]').find(jayson)]


print(a)

raise Exception('Parse error at %s:%s near token %s (%s)' % (t.lineno, t.col, t.value, t.type)) Exception: Parse error at 1:8 near token ( (()

I really do not know what is going on and it would be great if someone could help me! Thanks!

Upvotes: 0

Views: 1423

Answers (1)

GypsyKing25
GypsyKing25

Reputation: 3

So after some days of searching I managed to find the fix. As said in this github thread, changing imports manages to get it fixed.

Upvotes: 0

Related Questions