h2non / jsonpath-ng

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

[Issue] Cannot filter an element that has a null field value #49

Open idxn opened 4 years ago

idxn commented 4 years ago

JSON Example

{
  "firstName": "John",
  "lastName" : "doe",
  "age"      : 26,
  "address"  : {
    "streetAddress": "naist street",
    "city"         : "Nara",
    "postalCode"   : "630-0192"
  },
  "phoneNumbers": [
    {
      "type"  : "iPhone",
      "number": "0123-4567-8888",
      "carrier": "at&t"
    },
    {
      "type"  : "home",
      "number": "0123-4567-8910",
      "carrier": null
    }
  ]
}

I can use $.phoneNumbers[?(@.carrier==null)].type on https://jsonpath.com/ but the jsonpath-ng library always return an empty list

nivesnine commented 3 years ago

This is possible in jayway as described here. However, I haven't seen anything like DEFAULT_PATH_LEAF_TO_NULL in the codebase... still looking.

michaelmior commented 11 months ago

There's nothing like DEFAULT_PATH_LEAF_TO_NULL because it's not necessary. However, this is a bug since null gets wrongly treated as a string.

Sanoop-PM commented 6 months ago

@michaelmior Any update on this issue?

michaelmior commented 6 months ago

@Sanoop-PM Any updates will be posted here. A pull request to fix the issue would happily be accepted.