qntfy / kazaam

Arbitrary transformations of JSON in Golang
MIT License
282 stars 54 forks source link

Support for JSONPath Expression Filtering #86

Open powers-alan opened 6 years ago

powers-alan commented 6 years ago

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!

chilland commented 6 years ago

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

JoshuaC215 commented 6 years ago

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!