Open farshidtz opened 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.
Discussion in 22.8:
Issue #129 closed, should carry forward items discussed there as appropriate here. Removing "Consolidation" label.
FYI: JSONPath has just been released as RFC 9353 :) So for Discovery 2.0, we can use it as a normative reference.
@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 JaywayCan 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?
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']
According to this blog post, there are also at least these two online sandboxes available:
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