You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Erich Bremer <er...@ebremer.com> on 2020/09/15 20:13:20 UTC
bug in JSON LD parsing
The base URI of a jsonLD file doesn't appear to be swapped out correctly.
The first "./" is replaced correctly with the specified base, but after
that, blank nodes that don't end up in the final graph seem to be created.
See:
https://github.com/ebremer/jenabug
using the following code to read in a JSON-LD file:
Model m = ModelFactory.createDefaultModel();
InputStream inputStream = new FileInputStream("demo.jsonld");
RDFParser.create().base("https://demo.com
").source(inputStream).lang(RDFLanguages.JSONLD).parse(m);
System.out.println("Number of triples : "+m.size());
RDFDataMgr.write(System.out, m, Lang.NQUADS);
demo.jsonld:
{
"@context": [
"https://w3id.org/ro/crate/1.0/context"
],
"@graph": [
{
"@id": "blam.ttl",
"@type": "CreativeWork",
"about": {
"@id": "./another/local/3223423423"
}
},
{
"@type": "CreativeWork",
"@id": "ro-crate-metadata.jsonld",
"conformsTo": {
"@id": "https://w3id.org/ro/crate/1.0"
},
"about": {
"@id": "./"
}
}
]
}
Re: bug in JSON LD parsing
Posted by Andy Seaborne <an...@apache.org>.
:-)
https://lists.apache.org/thread.html/r343f27b3390dfbfd7ce9dcee4576bc532705b39d26923dfb0baf5322%40%3Cusers.jena.apache.org%3E
"""
From: Erich Bremer <er...@ebremer.com>
To: users@jena.apache.org
Subject: JSONLD and base URL
Date: 2020/03/04 00:10:20
"""
jsonld-java 0.13.1 with a fix for this was released recently on 2020-09-09.
JENA-1967 for an upgrade of jsonld-java.
Andy
On 15/09/2020 21:13, Erich Bremer wrote:
> The base URI of a jsonLD file doesn't appear to be swapped out correctly.
> The first "./" is replaced correctly with the specified base, but after
> that, blank nodes that don't end up in the final graph seem to be created.
>
> See:
> https://github.com/ebremer/jenabug
>
> using the following code to read in a JSON-LD file:
>
> Model m = ModelFactory.createDefaultModel();
> InputStream inputStream = new FileInputStream("demo.jsonld");
> RDFParser.create().base("https://demo.com
> ").source(inputStream).lang(RDFLanguages.JSONLD).parse(m);
> System.out.println("Number of triples : "+m.size());
> RDFDataMgr.write(System.out, m, Lang.NQUADS);
>
> demo.jsonld:
> {
> "@context": [
> "https://w3id.org/ro/crate/1.0/context"
> ],
> "@graph": [
> {
> "@id": "blam.ttl",
> "@type": "CreativeWork",
> "about": {
> "@id": "./another/local/3223423423"
> }
> },
> {
> "@type": "CreativeWork",
> "@id": "ro-crate-metadata.jsonld",
> "conformsTo": {
> "@id": "https://w3id.org/ro/crate/1.0"
> },
> "about": {
> "@id": "./"
> }
> }
> ]
> }
>