Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

[Feature Request] Conditional operators #168

Open
andykais opened this issue Dec 3, 2018 · 0 comments
Open

[Feature Request] Conditional operators #168

andykais opened this issue Dec 3, 2018 · 0 comments

Comments

@andykais
Copy link

andykais commented Dec 3, 2018

I would like to reopen the discussion on adding conditionals to the parse notation. There are two other (non stream based) jsonpath npm packages out there (jsonpath-plus and jsonpath) which have full use of the conditionals in the specification. I have a requirement for a library of mine where the logic for querying json has to be defined entirely separate from evaluated code. I love the idea of using streams as my query engine, since the incoming data comes from a node-fetch stream and after parsing is sent to an observable, but if I cannot do complex filtering, then I have no way of using JSONStream

There is an old issue on this repo #106 where you mention

It's interesting that you use the JSONPath expression though, when I was first implementing this, I did investigate several implementations of JSONPath-like things, but none of them where sufficiently stream-oriented to adapt to streaming json.

If this is still the case, can you elaborate? If not, could we discuss how it could be implemented in the future? I would be happy to open a PR if you have an implementation in mind.

example syntax

{
"store": {
  "book": [
    {
      "category": "reference",
      "author": "Nigel Rees",
      "title": "Sayings of the Century",
      "price": 8.95
    },
    {
      "category": "fiction",
      "author": "Herman Melville",
      "title": "Moby Dick",
      "isbn": "0-553-21311-3",
      "price": 8.99
    },
    {
      "category": "fiction",
      "author": "J. R. R. Tolkien",
      "title": "The Lord of the Rings",
      "isbn": "0-395-19395-8",
      "price": 22.99
    }
  ]
}
}

e.g. $.book[?(@.category=='fiction')]

Thank you for this library! Btw if you are interested, I have put together a performance comparison of all the json querying npm packages https://github.com/andykais/json-querying-performance-testing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant