h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
572 stars 85 forks source link

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

Open yangming9 opened 1 year ago

yangming9 commented 1 year ago

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 commented 1 year ago

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