Re: How should I query ActivityStreams objects containing both JSON and HTML?

On Fri, 31 Mar 2023 at 23:06, Bob Wyman <bob@wyman.us> wrote:

> In a Mastodon.social post
> <https://mastodon.social/@bobwyman/110120087223817037>, I asked:
>
> XPath and JSONPath are similar, but different. (See JSONPath spec
> <https://goessner.net/articles/JsonPath/>) This presents a problem for me
> since I'm building a system to query ActivityStreams objects that can
> include HTML wrapped in JSON.
>
> Should I:
>
>    - Use XPath syntax for both JSON and HTML?
>    - Use JSONPath syntax for both JSON and HTML? (If so, is there a
>    reasonable extension to JSONPath to support selecting on HTML attributes?)
>    - Switch between JSONPath and XPath depending on the underlying
>    datatype? (e.g. Embedding XPath in JSONPath.)
>
> If you were writing a query, would you accept needing to know both
> syntaxes?
>
> I would appreciate any advice you might be able to provide. Also, I would
> be interested to hear if anyone else has already been faced with and
> addressed this issue.
>

Hi Bob,

Never came across JSONPath before !

From a very quick look I would provide two functions :-
  - one that embeds XPath in the JSONPath expressions, but only if the
syntactic closure works correctly.
  - Another that uses the JSONPath following the correspondences table,
adding the '@' attribute .and the '()' grouping syntactic elements/

Very interesting !

Regards,

Aaron
--
Aaron Gray - @AaronNGray@fosstodon.org

Independent Open Source Software Engineer, Computer Language Researcher,
Information Theorist, and Computer Scientist.

Received on Friday, 31 March 2023 23:09:17 UTC