Skip to content

JsonPathParserError, when Objecttag contains only Number #46

@sm-ffm

Description

@sm-ffm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions