Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonPathParserError, when Objecttag contains only Number #46

Open
sm-ffm opened this issue Mar 8, 2024 · 0 comments
Open

JsonPathParserError, when Objecttag contains only Number #46

sm-ffm opened this issue Mar 8, 2024 · 0 comments

Comments

@sm-ffm
Copy link

sm-ffm commented Mar 8, 2024

I've got the following Error:

jsonpath_ng.exceptions.JsonPathParserError: Parse error at 1:2 near token 1 (NUMBER)

I tried a lot, and it only raises, when Objectag only contains Numbers. I tried it with parsing / finding Data and Editing Data. Both raises Error.

Example Code:

`import json
from jsonpath_ng import jsonpath, parse

def jsonparser(Path, Json):
json_data = json.loads(Json)
jsonpath_expression = parse(Path)
Output = jsonpath_expression.find(json_data)[0].value
return Output

def jsonEditvalue(Path, Json, Value):
json_data = json.loads(Json)
jsonpath_expr = parse(Path)
jsonpath_expr.find(json_data)
jsonpath_expr.update(json_data, Value)
Output = json.dumps(json_data, indent=2)
return Output

jsonstring = """
{
"1" : {
"One" : "Data1",
"Two" : "Data2",
"Three" : "Data3"
},
"2" : {
"One" : "Data1",
"Two" : "Data2",
"Three" : "Data3"
}
}
"""
print(jsonparser("$.1.One", jsonstring))
print(jsonEditvalue("$.1.One", jsonstring, "DataNew"))
`
jsonpath-ng is the first Parser I used with that Kind of Issue.

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

No branches or pull requests

1 participant