Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON-LD #88

Closed
fimbault opened this issue Aug 19, 2020 · 10 comments
Closed

JSON-LD #88

fimbault opened this issue Aug 19, 2020 · 10 comments

Comments

@fimbault
Copy link

Hi,

It's great to get json-ld 1.1 support, at least for serialization and parsing. Even if it's early stage, it could be interesting to list it on https://json-ld.org
What's the long term objective in terms of compliance with the rest of the spec? (flattening, compaction, framing)

Fabien

@pchampin
Copy link
Owner

What's the long term objective in terms of compliance with the rest of the spec? (flattening, compaction, framing)

Most algorithms in the spec take JSON as input and return JSON as output, so I consider them as slightly out-of-scope for Sophia (which is centered on the notion of RDF Graph). The only relevant algorithms for Sophia are therefore toRdf (i.e. a JSON-LD parser) and fromRdf (i.e. a JSON-LD serializer).

That being said, these two algorithms are not totally independant from the others:

  • toRdf explicitly relies on the expansion algorithm
  • fromRdf as described by the spec produces expanded JSON-LD, but a full-featured serializer should provide options to produce a compact JSON-LD document, according to a given context.

The way I see things:

  • a separate crate will implement the JSON-LD algorithms according to the JSON-LD spec (I have this one in mind, I am in contact with @timothee-haudebourg);
  • sophia_jsonld will depend on this crate to provide implementations of the Sophia traits for parsers and serializer.

@roper79
Copy link

roper79 commented Jan 26, 2023

Hi, is there any progress/plans with a JSON-LD parser front? Thanks!

@pchampin
Copy link
Owner

at long (long) last, there is indeed some progress! d6d73d7

Long story short: there is now a sophia_jsonld crate providing a JSON-LD parser and a JSON-LD serializer (producing only the expanded form at the moment).

@damooo
Copy link
Contributor

damooo commented Oct 4, 2023

@pchampin Could you release the update to crates.io?

@pchampin
Copy link
Owner

pchampin commented Oct 4, 2023

Could you release the update to crates.io?

I still have a few adjustments to make, but I will eventually.

Note that you can still use the commit as a dependency in cargo with

sophia = { git = "https://github.com/pchampin/sophia_rs.git", rev = "d6d73d78" }

Of course, you don't want to release on crates.io a crate with this kind of dependencies (I guess the server won't let you, anyway), but for a work in progress, that's a good solution.

@LuisOsta
Copy link

@pchampin Trying out that commit but I wanted to let you know that if I try the latest commit instead I get an error due to a lack of the futures_util module being present in the library consumer. Here's more context on the error:

   Compiling predicates-tree v1.0.9
   Compiling chrono v0.4.31
   Compiling json-ld-compaction v0.15.0
   Compiling sophia_resource v0.8.0-alpha.3 (https://github.com/pchampin/sophia_rs.git?rev=f16ec404cad433a8a7679ab991b5d7189da76ffe#f16ec404)
error[E0432]: unresolved import `futures_util`
 --> /Users/luisosta/.cargo/git/checkouts/sophia_rs-ca1fdaaafda2a8dd/f16ec40/resource/src/loader/_trait.rs:3:5
  |
3 | use futures_util::FutureExt;
  |     ^^^^^^^^^^^^ use of undeclared crate or module `futures_util`

   Compiling sophia_term v0.8.0-alpha.3 (https://github.com/pchampin/sophia_rs.git?rev=f16ec404cad433a8a7679ab991b5d7189da76ffe#f16ec404)
   Compiling pin-project v1.1.3
For more information about this error, try `rustc --explain E0432`.
error: could not compile `sophia_resource` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...

@pchampin
Copy link
Owner

pchampin commented Nov 15, 2023

@LuisOsta I noticed that, and it should now be fixed.
The problem was :

  • you need to enable the jsonld feature to have JSON-LD support
  • the line causing the error with futures_util should have been included only when the feature is enabled, because futures_util is not included otherwise.

With the latest commit, the crate should compile with or withour the jsonld feature enabled. But of course, in your case, you should enable it!

@pchampin
Copy link
Owner

@pchampin Could you release the update to crates.io?

@damooo by the way, I forgot to mention that the JSON-LD support was included in [version 0.8.0-alpha.3](https://crates.io/crates/sophia_api/0.8.0-alpha.3

Regarding the initial suggestion of this issue (adding Sophia to the list of JSON-LD implementations on json-ld.org): since Sophia is based on https://github.com/timothee-haudebourg/json-ld, and since that implementation is already mentioned there, I don't think it is appropriate to add Sophia to that list.

@damooo
Copy link
Contributor

damooo commented Nov 15, 2023

JSON-LD support was included in [version 0.8.0-alpha.3]

Saw that already _/\_.

Now basic support is added in manas.

It also adds json-ld support to rdf_dynsyn crate (not yet updated in crates.io), to be dynamically specified. And also includes a custom http loader, that allows for caching/any-middleware, and fixes few issues in existing loader.

@LuisOsta
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants