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

Compact serialization #93

Open
sharpaper opened this issue Jul 7, 2020 · 7 comments
Open

Compact serialization #93

sharpaper opened this issue Jul 7, 2020 · 7 comments

Comments

@sharpaper
Copy link

sharpaper commented Jul 7, 2020

Is g.serialize() supposed to produce a compacted jsonld document? If I have this graph [node_a]->knows->[blank_node], when I retrieve node_a with rdflib and then serialize with rdflib-jsonld, I obtain this document

{
    "@context": [...],
    "@graph": [
        {
            "name": "Alice"
            "knows": { "id": "_:xxxxx" }
        },
        {
            "id": "_:xxxxx"
        }
    ]
}

whereas I would expect this

{
    "@context": [...],
    "name": "Alice"
    "knows": "_:xxxxx" 
}

Am I doing something wrong?

@jbkoh
Copy link

jbkoh commented Aug 26, 2020

I'd be interested in this issue too. I understand it's easier to assign ids to blank nodes for serialization, but one of the upsides of JSON-LD is the nested format with JSON, which is more human-readable.

@westurner
Copy link

See also #52 :

How to use this from the command line with rdfpipe to convert from one format to another (with optional {compaction,}) could be helpfully added to README.rst.

@nicholascar
Copy link
Member

The RDFlib maintainers are hoping to see JSON-LD 1.1 support completed soon and then for this package to me merged into the main RDFlib package as a main serializer/parser plugin.

If any of you are interested in completing JSON-LD 1.1 support in order to then take up other issues, such as this one, please let me or the rdflib-dev mailing list know. We have a couple of developers getting ready to look into this but more help will be greatly appreciated.

@westurner
Copy link

Is PyLD the only JSON-LD implementation with support for compaction at present? https://github.com/digitalbazaar/pyld/blob/316fbc2c9e25b3cf718b4ee189012a64b91f17e7/tests/runtests.py#L664

I don't think this issue should block the new rdflib major release which will hopefully contain a completed integrated json-ld 1.1 parser/serializer. Looking at https://rdflib.dev/ , JSON-LD [1.1] compaction (and docs for how to specify the serializer format parameter w/ the RDFlib API and the rdfpipe CLI [#52]) would probably entail a minor version bump to e.g. 6.1.0?

@nicholascar
Copy link
Member

I don't think this issue should block the new rdflib major release

Agreed. We discussed just bringing rdflib-jsonld into main rdflib right now but I think it sensible to prove the 1.1 support and then do that, since the support is part-way implemented already. Then we retain the Issues/PRs and commit history that added the 1.1 support here for historical record but port over all issues such as this to the main rdflib Issues tracker.

@sblack-usu
Copy link

This is something I have interest in as well. Has there been any movement on supporting compact serialization of json-ld?

@westurner
Copy link

From google/yamlfmt#125 ; it's called JSON-LD Framing :

reframe/compact/expand the underlying JSON-LD graph

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