How to use json-ld?


i am trying to… grasp… how to talk to xtdb2 using the recently advertised json-ld… but frankly, that seems even harder than guessing Transit :confused:

i have some idea of RDF/ SPARQL/ - that linked-things-world - but how do i get the schema / context to which to match the eventual query-result json?

XTDB OpenAPI Specification does not really help…

copy-pasting the example result from XTDB OpenAPI Specification
JSON-LD Playground
results in emptiness-or-validation errors (only visualization works) which is expected… no context.

btw… the only 2 libs handling this json-ld stuff in python, are last touched about
7-10y ago. Maybe the stuff did not change… like transit? that is also from 2014

btw in my current setup, seems xtdb is the bottleneck, and actually talking to it (i.e. EDN-ing or Transit-ing ), not the actual work on either side. Looking at above RDF stuff, i don’t think json-LD would be any faster.

Kind-a devils-advocate, but how about gRPC ?

have fun

Hey @svil it’s probably better to think of it as a regular JSON API that happens to borrow JSON-LD’s mechanism for encoding non-JSON types, e.g. encoding a duration as an object:

  "@type": "xt:duration",
  "@value": "PT3H1M35.23S"

…where the use of @type, @value and xt: namespacing looks approximately like the JSON-LD conventions.

I don’t think there is anything else in the API currently which resembles or behaves like JSON-LD in particular - so the confusion here is almost certainly my fault due to over-emphasising the “LD” suffix too much - apologies!

Does that help?

how about gRPC ?

It’s definitely interesting - and somewhat similar to - for the time being though we hope the JSON API has lowered the barrier for client experimentation and development. In contrast, and as far as I’m aware, the gRPC toolchains across various languages are still nowhere near as easy to get started with compared to JSON.