The error is arising because the jsonpath_ng library appears to interpret the /
symbol as numeric division, not as a valid character in identifiers.
At the same time, however, it's unusual (though not impossible) for the JSON to have /
characters in property names.
As I see it, what you need to do depends on the data you have:
If your JSON genuinely has a /
character in property names, i.e. it looks like the following:
{"paths": {"/createJob": {"post": ... } } }
then you'll need to use the bracket notation (['propertyname']
) instead of the dot notation (.propertyname
):
jsonpath_expression = parse("$.paths['/createJob'].post.parameters[0].schema.$ref")
If your JSON doesn't actually have /
characters in property names, then you should just delete the /
from your JSON Path expression.
Note that I cannot guarantee either of these approaches to return data, because you haven't provided any sample data to query nor the expected result of running the JSON Path query.