w3c / wot-discovery

Repository for WoT discovery discussion
https://w3c.github.io/wot-discovery/
Other
19 stars 17 forks source link

JSONPath as a search query language #234

Open farshidtz opened 2 years ago

farshidtz commented 2 years ago

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 commented 2 years ago

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

mmccool commented 2 years ago

Discussion in 22.8:

mmccool commented 1 year ago

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

JKRhb commented 7 months ago

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

benfrancis commented 7 months ago

@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.

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 commented 7 months ago

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 commented 7 months ago

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