Hi Andy,
this ist he output when using JsonUtils:
{
"@default" : [ {
"subject" : {
"type" : "IRI",
"value" : "urn:dev:ops:32473-wotdirectory-1234"
},
"predicate" : {
"type" : "IRI",
"value" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
},
"object" : {
"type" : "IRI",
"value" : "https://w3id.org/saref#Device"
}
}, {
"subject" : {
"type" : "IRI",
"value" : "urn:dev:ops:32473-wotdirectory-1234"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasActionAffordance"
},
"object" : {
"type" : "blank node",
"value" : "_:b0"
}
}, {
"subject" : {
"type" : "IRI",
"value" : "urn:dev:ops:32473-wotdirectory-1234"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasForm"
},
"object" : {
"type" : "blank node",
"value" : "_:b5"
}
}, {
"subject" : {
"type" : "IRI",
"value" : "urn:dev:ops:32473-wotdirectory-1234"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasPropertyAffordance"
},
"object" : {
"type" : "blank node",
"value" : "_:b6"
}
}, {
"subject" : {
"type" : "IRI",
"value" : "urn:dev:ops:32473-wotdirectory-1234"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasPropertyAffordance"
},
"object" : {
"type" : "blank node",
"value" : "_:b9"
}
}, {
"subject" : {
"type" : "IRI",
"value" : "urn:dev:ops:32473-wotdirectory-1234"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasPropertyAffordance"
},
"object" : {
"type" : "blank node",
"value" : "_:b12"
}
}, {
"subject" : {
"type" : "IRI",
"value" : "urn:dev:ops:32473-wotdirectory-1234"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#securityDefinitions"
},
"object" : {
"type" : "blank node",
"value" : "_:b14"
}
}, {
"subject" : {
"type" : "IRI",
"value" : "urn:dev:ops:32473-wotdirectory-1234"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#title"
},
"object" : {
"type" : "literal",
"value" : "Directory Service",
"datatype" : "http://www.w3.org/2001/XMLSchema#string"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b0"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#description"
},
"object" : {
"type" : "literal",
"value" : "Allows to register a new resource.",
"datatype" : "http://www.w3.org/2001/XMLSchema#string"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b0"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasForm"
},
"object" : {
"type" : "blank node",
"value" : "_:b1"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b0"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasInputSchema"
},
"object" : {
"type" : "blank node",
"value" : "_:b2"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b0"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasOutputSchema"
},
"object" : {
"type" : "blank node",
"value" : "_:b3"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b0"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasUriTemplateVariable"
},
"object" : {
"type" : "blank node",
"value" : "_:b4"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b1"
},
"predicate" : {
"type" : "IRI",
"value" : "htv:methodName"
},
"object" : {
"type" : "literal",
"value" : "POST",
"datatype" : "http://www.w3.org/2001/XMLSchema#string"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b6"
},
"predicate" : {
"type" : "IRI",
"value" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
},
"object" : {
"type" : "IRI",
"value" : "https://w3id.org/saref#Temperature"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b6"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#description"
},
"object" : {
"type" : "literal",
"value" : "Temperature",
"datatype" : "http://www.w3.org/2001/XMLSchema#string"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b6"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasForm"
},
"object" : {
"type" : "blank node",
"value" : "_:b7"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b6"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasForm"
},
"object" : {
"type" : "blank node",
"value" : "_:b8"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b6"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#isObservable"
},
"object" : {
"type" : "literal",
"value" : "true",
"datatype" : "http://www.w3.org/2001/XMLSchema#boolean"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b7"
},
"predicate" : {
"type" : "IRI",
"value" : "htv:methodName"
},
"object" : {
"type" : "literal",
"value" : "GET",
"datatype" : "http://www.w3.org/2001/XMLSchema#string"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b9"
},
"predicate" : {
"type" : "IRI",
"value" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
},
"object" : {
"type" : "IRI",
"value" : "https://w3id.org/saref#OnOffState"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b9"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#description"
},
"object" : {
"type" : "literal",
"value" : "is database running",
"datatype" : "http://www.w3.org/2001/XMLSchema#string"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b9"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasForm"
},
"object" : {
"type" : "blank node",
"value" : "_:b10"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b9"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasForm"
},
"object" : {
"type" : "blank node",
"value" : "_:b11"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b9"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#isObservable"
},
"object" : {
"type" : "literal",
"value" : "true",
"datatype" : "http://www.w3.org/2001/XMLSchema#boolean"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b10"
},
"predicate" : {
"type" : "IRI",
"value" : "htv:methodName"
},
"object" : {
"type" : "literal",
"value" : "GET",
"datatype" : "http://www.w3.org/2001/XMLSchema#string"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b12"
},
"predicate" : {
"type" : "IRI",
"value" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
},
"object" : {
"type" : "IRI",
"value" : "https://w3id.org/saref#OnOffState"
}
}, {
"subject" : {
"type" : "blank node",
"value" : "_:b12"
},
"predicate" : {
"type" : "IRI",
"value" : "https://www.w3.org/2019/wot/td#hasForm"
},
"object" : {
"type" : "blank node",
"value" : "_:b13"
}
} ]
}
But when i use RDFDataMgr.read(dataset, in, Lang.JSONLD) and write it with
RDFDataMgr.writ(System.out, dataset, Lang.JSONLD) the output is:
{ }
Any idea?
Best regards
Phil
-----Ursprüngliche Nachricht-----
Von: Andy Seaborne <[email protected]>
Gesendet: Sonntag, 25. Juli 2021 11:59
An: [email protected]
Betreff: Re: Storing ThingDescription in Dataset
Hi Phil,
Jena has an RDF reader that wraps up the use of jsonld-java so you don't
have to use jsonld-java code directly.
InputStream in = ...
Dataset dataset = ...
RDFDataMgr.read(dataset, in, Lang.JSONLD);
If you want to see the source code to see how it uses JsonLdProcessor.toRDF,
the Jena code is
org.apache.jena.riot.lang.JsonLDReader
If you have the data in a file with a jsonld file extension, you can just
read the file directly e.g. if you want to run Fuseki separately from the
production of the WoT descriptions.
Andy
On 25/07/2021 09:18, Philipp Leeb wrote:
> Hey guys,
>
>
>
> I'm trying to store a WoT-TD (JSON-LD format) in Dataset of embedded
fuseki.
> When using:
>
>
>
> InputStream inputStream = new
> ByteArrayInputStream(exposedThing.toJson().getBytes(StandardCharsets.U
> TF_8))
> ;
> Object jsonObject = JsonUtils.fromInputStream(inputStream);
> Object compact = JsonLdProcessor.toRDF(jsonObject);
>
>
>
> The compact-Object is a list of triples, so i assume it's correct. But
> somehow i don't get it how to read this into a dataset. Can anyone help
me?
>
>
>
> Best regards
>
> Phil
>
>