Open mmccool opened 4 years ago
Use case: Search for things which have HTTP endpoint
@k-toumura: nodegen only support HTTP and WebSocket, so I want to filter out TDs which doesn’t have HTTP or Websocket endpoint.
The utilized JSONPath library doesn't support recursive descent for filtering. This can still be done if the path is known, e.g.:
$[?(@.properties.brightness.forms[0].href=~/^http/)]
.
To filter with XPath based on href inside form objects anywhere in the TD (incl. root level, inside interaction affordances):
*[*//forms/*[starts-with(href, 'http')]]
So apparently the JSON Path syntax does support recursion, but not all implementations do.
JSONPath is simpler (and lacks a formal specification, and implementations vary...), but XPath is more full-featured and better specified. It turns out some of the XPath features are useful and important for directory search... and we can depend on them, since they are actually required by a specification.