kazaam icon indicating copy to clipboard operation
kazaam copied to clipboard

Support for JSONPath Expression Filtering

Open powers-alan opened this issue 6 years ago • 2 comments

Hey qntfy Crew! Does your library have any support for JSONPath expression filtering?
For example: Input

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

Path phoneNumbers[?(@.type == "iPhone")].number Result

[
  "0123-4567-8888"
]

Looking through the code briefly I don't see anything that would support filtering, so I think the answer is probably no. If the library doesn't support this syntax would this be a contribution that would be welcome? Thanks!

powers-alan avatar Aug 23 '18 21:08 powers-alan

Hi @powers-alan, no we don't currently support anything like that. But yes, we are definitely open to contributions.

chilland avatar Aug 29 '18 01:08 chilland

Hey @powers-alan just chiming in to note that this change would be most elegant in https://github.com/qntfy/jsonparser which provides underlying parsing for kazaam. Thank you!

JoshuaC215 avatar Sep 06 '18 20:09 JoshuaC215