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

jsonpath_ng.exceptions.JsonPathParserError: Parse error at 1:37 near token 1 (NUMBER) #123

Closed
yangming9 opened this issue Apr 14, 2023 · 3 comments

Comments

@yangming9
Copy link

yangming9 commented Apr 14, 2023

my patch key contain a number as a key(but it is real a str),Can we be compatible with this format

my json example : {
    "modular": 213,
    "enable": true,
    "info":[
        {
          "feature_param_dict_list": [{
                "1" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                "2" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                "3" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                "4" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                "5" : [0],
                "6" : [0],
                "7" : [0, 0, 0, 0],
                "8" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                "9" : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                "10": [0, 0]
              }
          ]
        }]
}

my path example : $.info[*].feature_param_dict_list[*].1[0]

@michaelmior
Copy link
Collaborator

You should be able to quote the 1 and use the path $.info[*].feature_param_dict_list[*].["1"][0].

@enkeefe-flexgen
Copy link

Fair, but other JSONPath programs consider something like $.info[0].feature_param_dict_list[0].1 as a valid path to get the value of the "1" key in the feature_param_dict_list. I have ran into this issue as well for some of my data and it would be wonderful if paths like the one above were supported.

@michaelmior
Copy link
Collaborator

This just required a change to the parser that doesn't appear to break any existing code, so this should be fixed in the next release.

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

3 participants