Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONPath as a search query language #234

Open
farshidtz opened this issue Nov 22, 2021 · 7 comments
Open

JSONPath as a search query language #234

farshidtz opened this issue Nov 22, 2021 · 7 comments

Comments

@farshidtz
Copy link
Member

farshidtz commented Nov 22, 2021

We propose the use of JSONPath as one of the query languages in the discovery spec. However, we can't propose that as a normatice recommendation since the specification of JSONPath is not yet a standard.

We now have several issues addressing this very same problem:

The goal of this issue is solely to monitor the progress of JSONPath standardization.

IETF datatracker: https://datatracker.ietf.org/doc/html/draft-ietf-jsonpath-base
Feature matrix of most existing implementations: https://cburgmer.github.io/json-path-comparison/#filter_expression_with_regular_expression

@mmccool
Copy link
Contributor

mmccool commented Apr 11, 2022

Has been resolved (we have to make it informative at best, which has been done) so I think we can close this issue.

@mmccool
Copy link
Contributor

mmccool commented Aug 22, 2022

Discussion in 22.8:

  • if aim for Discovery 1.1 that allows for compatibility, can at most make this an optional feature
  • Probably a good idea for our next release to be backward-compatible to maximize adoption
  • could make it a "SHOULD" assertion, though... and if testing works out, mandatory in 2.0 (although of course we can discuss later after implementation experience)

@mmccool
Copy link
Contributor

mmccool commented Mar 6, 2023

Issue #129 closed, should carry forward items discussed there as appropriate here. Removing "Consolidation" label.

@JKRhb
Copy link
Member

JKRhb commented Feb 22, 2024

FYI: JSONPath has just been released as RFC 9353 :) So for Discovery 2.0, we can use it as a normative reference.

@benfrancis
Copy link
Member

@JKRhb: I can't tell from skim-reading this RFC whether it includes a standardised operator/filter/selector/some other mechanism for filtering objects in an array by the presence of a string in an array inside the object.

In #387 this is needed for searching a directory for Thing Descriptions which have a particular value in their @type array.

e.g.

  • $[?(@['@type'].indexOf('iot:TemperatureSensor') != -1)] in Goessner JSONPath, or:
  • $[?('iot:TemperatureSensor' in @['@type'])] in Jayway

Can anyone figure out if there is now a standardised way to do this? Perhaps via some kind of nested match expression? Or are there implementations which support this latest RFC that we can experiment with?

@JKRhb
Copy link
Member

JKRhb commented Feb 26, 2024

I only skimmed through the document myself so far, but at first glance, it seems to me as if you can use the filter selector for that. If I am not mistaken, with the RFC's syntax, the filter would then look something like this:

$[?(@['@type'] == 'iot:TemperatureSensor')]

Edit:

After some testing with one of the sandboxes, it seems as if the query should actually look like this (if I understood the examples you gave correctly):

$['@type'][?@ == 'iot:TemperatureSensor']

@JKRhb
Copy link
Member

JKRhb commented Feb 26, 2024

According to this blog post, there are also at least these two online sandboxes available:

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

No branches or pull requests

4 participants