You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Philipp Leeb <p_...@t-online.de> on 2021/07/25 08:18:10 UTC

Storing ThingDescription in Dataset

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.UTF_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


AW: AW: Storing ThingDescription in Dataset

Posted by Philipp Leeb <p_...@t-online.de>.
This would be my dependency-tree:
[INFO] org.leebphil:wot-td-query:jar:0.0.1-SNAPSHOT
[INFO] +- org.apache.jena:apache-jena-libs:pom:4.1.0:compile
[INFO] |  +- org.apache.jena:jena-shacl:jar:4.1.0:compile
[INFO] |  |  \- org.apache.jena:jena-arq:jar:4.1.0:compile
[INFO] |  |     +- org.apache.jena:jena-core:jar:4.1.0:compile
[INFO] |  |     |  +- org.apache.jena:jena-base:jar:4.1.0:compile
[INFO] |  |     |  |  +- org.apache.jena:jena-shaded-guava:jar:4.1.0:compile
[INFO] |  |     |  |  +- org.apache.commons:commons-csv:jar:1.8:compile
[INFO] |  |     |  |  +- org.apache.commons:commons-compress:jar:1.20:compile
[INFO] |  |     |  |  \- com.github.andrewoma.dexx:collection:jar:0.7:compile
[INFO] |  |     |  +- org.apache.jena:jena-iri:jar:4.1.0:compile
[INFO] |  |     |  \- commons-cli:commons-cli:jar:1.4:compile
[INFO] |  |     \- org.apache.thrift:libthrift:jar:0.14.1:compile
[INFO] |  |        \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  +- org.apache.jena:jena-tdb:jar:4.1.0:compile
[INFO] |  +- org.apache.jena:jena-tdb2:jar:4.1.0:compile
[INFO] |  |  \- org.apache.jena:jena-dboe-storage:jar:4.1.0:compile
[INFO] |  |     \- org.apache.jena:jena-dboe-trans-data:jar:4.1.0:compile
[INFO] |  |        +- org.apache.jena:jena-dboe-transaction:jar:4.1.0:compile
[INFO] |  |        |  \- org.apache.jena:jena-dboe-base:jar:4.1.0:compile
[INFO] |  |        \- org.apache.jena:jena-dboe-index:jar:4.1.0:compile
[INFO] |  \- org.apache.jena:jena-rdfconnection:jar:4.1.0:compile
[INFO] +- org.apache.jena:jena-fuseki-main:jar:4.1.0:compile
[INFO] |  +- org.apache.jena:jena-fuseki-core:jar:4.1.0:compile
[INFO] |  |  +- commons-fileupload:commons-fileupload:jar:1.4:compile
[INFO] |  |  +- org.eclipse.jetty:jetty-servlet:jar:9.4.40.v20210413:compile
[INFO] |  |  |  +- org.eclipse.jetty:jetty-security:jar:9.4.40.v20210413:compile
[INFO] |  |  |  |  \- org.eclipse.jetty:jetty-server:jar:9.4.40.v20210413:compile
[INFO] |  |  |  \- org.eclipse.jetty:jetty-util-ajax:jar:9.4.40.v20210413:compile
[INFO] |  |  +- org.eclipse.jetty:jetty-servlets:jar:9.4.40.v20210413:compile
[INFO] |  |  |  +- org.eclipse.jetty:jetty-continuation:jar:9.4.40.v20210413:compile
[INFO] |  |  |  +- org.eclipse.jetty:jetty-http:jar:9.4.40.v20210413:compile
[INFO] |  |  |  \- org.eclipse.jetty:jetty-io:jar:9.4.40.v20210413:compile
[INFO] |  |  +- io.micrometer:micrometer-core:jar:1.6.6:compile
[INFO] |  |  |  +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
[INFO] |  |  |  \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
[INFO] |  |  \- io.micrometer:micrometer-registry-prometheus:jar:1.6.6:compile
[INFO] |  |     \- io.prometheus:simpleclient_common:jar:0.9.0:compile
[INFO] |  |        \- io.prometheus:simpleclient:jar:0.9.0:compile
[INFO] |  +- org.apache.jena:jena-fuseki-access:jar:4.1.0:compile
[INFO] |  +- org.apache.jena:jena-cmds:jar:4.1.0:compile
[INFO] |  \- org.eclipse.jetty:jetty-xml:jar:9.4.40.v20210413:compile
[INFO] |     \- org.eclipse.jetty:jetty-util:jar:9.4.40.v20210413:compile
[INFO] +- junit:junit:jar:4.13.1:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- city.sane.wot-servient:wot-servient:jar:1.16-SNAPSHOT:compile
[INFO] |  +- com.damnhandy:handy-uri-templates:jar:2.1.8:compile
[INFO] |  |  \- joda-time:joda-time:jar:2.10.2:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.10.5:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.10.5:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.5:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.10.5:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-client:jar:3.0.0:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.11:compile
[INFO] |  |  +- commons-codec:commons-codec:jar:1.11:compile
[INFO] |  |  +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
[INFO] |  |  +- com.opencsv:opencsv:jar:4.3.2:compile
[INFO] |  |  +- org.apache.commons:commons-lang3:jar:3.8.1:compile
[INFO] |  |  +- org.apache.commons:commons-text:jar:1.3:compile
[INFO] |  |  +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] |  |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  |  +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] |  |  +- org.apache.commons:commons-collections4:jar:4.2:compile
[INFO] |  |  +- com.github.jsonld-java:jsonld-java:jar:0.12.3:compile
[INFO] |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.26:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient-cache:jar:4.5.9:compile
[INFO] |  |  \- commons-io:commons-io:jar:2.6:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-repository-sail:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-repository-api:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-sail-api:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-http-client:jar:3.0.0:compile
[INFO] |  |  |  +- org.eclipse.rdf4j:rdf4j-http-protocol:jar:3.0.0:compile
[INFO] |  |  |  |  \- org.eclipse.rdf4j:rdf4j-rio-ntriples:jar:3.0.0:compile
[INFO] |  |  |  +- org.eclipse.rdf4j:rdf4j-queryresultio-api:jar:3.0.0:compile
[INFO] |  |  |  \- org.eclipse.rdf4j:rdf4j-queryresultio-binary:jar:3.0.0:runtime
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-queryparser-api:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-queryalgebra-model:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-query:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-rio-api:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-rio-trig:jar:3.0.0:compile
[INFO] |  |  |  +- org.eclipse.rdf4j:rdf4j-rio-datatypes:jar:3.0.0:runtime
[INFO] |  |  |  \- org.eclipse.rdf4j:rdf4j-rio-languages:jar:3.0.0:runtime
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-model:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-queryalgebra-evaluation:jar:3.0.0:compile
[INFO] |  |  |  +- org.eclipse.rdf4j:rdf4j-repository-sparql:jar:3.0.0:compile
[INFO] |  |  |  |  +- org.eclipse.rdf4j:rdf4j-queryparser-sparql:jar:3.0.0:compile
[INFO] |  |  |  |  \- org.eclipse.rdf4j:rdf4j-queryresultio-sparqlxml:jar:3.0.0:compile
[INFO] |  |  |  +- org.mapdb:mapdb:jar:1.0.8:compile
[INFO] |  |  |  \- com.google.guava:guava:jar:18.0:compile
[INFO] |  |  \- org.eclipse.rdf4j:rdf4j-rio-turtle:jar:3.0.0:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-sail-memory:jar:3.0.0:compile
[INFO] |  |  +- org.eclipse.rdf4j:rdf4j-sail-base:jar:3.0.0:compile
[INFO] |  |  \- org.eclipse.rdf4j:rdf4j-util:jar:3.0.0:compile
[INFO] |  +- com.typesafe:config:jar:1.4.1:compile
[INFO] |  +- io.github.classgraph:classgraph:jar:4.8.109:compile
[INFO] |  +- io.netty:netty-transport:jar:4.1.65.Final:compile
[INFO] |  |  +- io.netty:netty-common:jar:4.1.65.Final:compile
[INFO] |  |  +- io.netty:netty-buffer:jar:4.1.65.Final:compile
[INFO] |  |  \- io.netty:netty-resolver:jar:4.1.65.Final:compile
[INFO] |  +- io.netty:netty-codec:jar:4.1.65.Final:compile
[INFO] |  +- io.reactivex.rxjava3:rxjava:jar:3.0.13:compile
[INFO] |  |  \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.32:compile
[INFO] +- city.sane.wot-servient:wot-servient-binding-http:jar:1.13:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.6:compile
[INFO] |  +- com.sparkjava:spark-core:jar:2.9.1:compile
[INFO] |  |  +- org.eclipse.jetty:jetty-webapp:jar:9.4.18.v20190429:compile
[INFO] |  |  +- org.eclipse.jetty.websocket:websocket-server:jar:9.4.18.v20190429:compile
[INFO] |  |  |  +- org.eclipse.jetty.websocket:websocket-common:jar:9.4.18.v20190429:compile
[INFO] |  |  |  \- org.eclipse.jetty.websocket:websocket-client:jar:9.4.18.v20190429:compile
[INFO] |  |  |     \- org.eclipse.jetty:jetty-client:jar:9.4.18.v20190429:compile
[INFO] |  |  \- org.eclipse.jetty.websocket:websocket-servlet:jar:9.4.18.v20190429:compile
[INFO] |  |     +- org.eclipse.jetty.websocket:websocket-api:jar:9.4.18.v20190429:compile
[INFO] |  |     \- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] |  \- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |     \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.13.1:compile
[INFO] |  +- org.apache.logging.log4j:log4j-api:jar:2.13.1:compile
[INFO] |  \- org.apache.logging.log4j:log4j-core:jar:2.13.1:runtime
[INFO] +- com.apicatalog:titanium-json-ld:jar:1.1.0:compile
[INFO] \- org.glassfish:jakarta.json:jar:2.0.0:compile

There is just one import of commons-codec with version 1.11 

-----Ursprüngliche Nachricht-----
Von: Andy Seaborne <an...@apache.org> 
Gesendet: Samstag, 31. Juli 2021 11:54
An: users@jena.apache.org
Betreff: Re: AW: Storing ThingDescription in Dataset


> But i get:
> Exception in thread "main" 
> org.apache.jena.ext.com.google.common.util.concurrent.ExecutionError: 
> java.lang.NoClassDefFoundError: 
> org/apache/commons/codec/digest/MurmurHash3

No commons-codec on the classpath, or there is an old version being picked up by dependency resolution via a different route (maybe Apache HttpComponents).

Its not uncommon to have dependences with quite old commons-codec dependencies - Jena v4.1.0 was built compiling with commons-code v1.15.

Resolution in maven is "closest" - shortest path to dependency.

MurmurHash3 is a relatively recent addition to commons-codec.

     Andy


AW: AW: Storing ThingDescription in Dataset

Posted by Philipp Leeb <p_...@t-online.de>.
Nvm, fixed dependency problem and this fixes my problem.


-----Ursprüngliche Nachricht-----
Von: Andy Seaborne <an...@apache.org> 
Gesendet: Samstag, 31. Juli 2021 11:54
An: users@jena.apache.org
Betreff: Re: AW: Storing ThingDescription in Dataset


> But i get:
> Exception in thread "main" 
> org.apache.jena.ext.com.google.common.util.concurrent.ExecutionError: 
> java.lang.NoClassDefFoundError: 
> org/apache/commons/codec/digest/MurmurHash3

No commons-codec on the classpath, or there is an old version being picked up by dependency resolution via a different route (maybe Apache HttpComponents).

Its not uncommon to have dependences with quite old commons-codec dependencies - Jena v4.1.0 was built compiling with commons-code v1.15.

Resolution in maven is "closest" - shortest path to dependency.

MurmurHash3 is a relatively recent addition to commons-codec.

     Andy


Re: AW: Storing ThingDescription in Dataset

Posted by Andy Seaborne <an...@apache.org>.
> But i get:
> Exception in thread "main" org.apache.jena.ext.com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/MurmurHash3

No commons-codec on the classpath, or there is an old version being 
picked up by dependency resolution via a different route (maybe Apache 
HttpComponents).

Its not uncommon to have dependences with quite old commons-codec 
dependencies - Jena v4.1.0 was built compiling with commons-code v1.15.

Resolution in maven is "closest" - shortest path to dependency.

MurmurHash3 is a relatively recent addition to commons-codec.

     Andy

AW: Storing ThingDescription in Dataset

Posted by Philipp Leeb <p_...@t-online.de>.
Hey,

when printing the N-Quads of titanium i get:
_:b0 <http://purl.org/dc/terms/description> "Allows to register a new resource." .
_:b0 <https://www.w3.org/2019/wot/td#hasForm> _:b1 .
_:b0 <https://www.w3.org/2019/wot/td#hasInputSchema> _:b2 .
_:b0 <https://www.w3.org/2019/wot/td#hasOutputSchema> _:b3 .
_:b0 <https://www.w3.org/2019/wot/td#hasUriTemplateSchema> _:b4 .
_:b0 <https://www.w3.org/2019/wot/td#name> "addNewResource" .
_:b1 <http://www.w3.org/2011/http#methodName> "POST" .
_:b1 <https://www.w3.org/2019/wot/hypermedia#forContentType> "application/json" .
_:b1 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/td#invokeAction> .
_:b10 <http://www.w3.org/2011/http#methodName> "GET" .
_:b10 <https://www.w3.org/2019/wot/hypermedia#forContentType> "application/json" .
_:b10 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/td#readProperty> .
_:b10 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseRunning> .
_:b11 <https://www.w3.org/2019/wot/hypermedia#forContentType> "application/json" .
_:b11 <https://www.w3.org/2019/wot/hypermedia#forSubProtocol> "longpoll" .
_:b11 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/td#observeProperty> .
_:b11 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseRunning/observable> .
_:b12 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/saref#OnOffState> .
_:b12 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/json-schema#StringSchema> .
_:b12 <https://www.w3.org/2019/wot/td#hasForm> _:b13 .
_:b12 <https://www.w3.org/2019/wot/td#name> "status" .
_:b13 <https://www.w3.org/2019/wot/hypermedia#forContentType> "application/json" .
_:b13 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/td#readProperty> .
_:b13 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/td#writeProperty> .
_:b13 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/status> .
_:b14 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/security#BasicSecurityScheme> .
_:b14 <https://www.w3.org/2019/wot/security#in> "header" .
_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/json-schema#ObjectSchema> .
_:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/json-schema#StringSchema> .
_:b4 <https://www.w3.org/2019/wot/td#name> "resource" .
_:b4 <https://www.w3.org/2019/wot/td#type> "string" .
_:b5 <https://www.w3.org/2019/wot/hypermedia#forContentType> "application/json" .
_:b5 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/hypermedia#readallproperty> .
_:b5 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/hypermedia#readmultipleproperty> .
_:b5 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/all/properties> .
_:b6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/saref#Temperature> .
_:b6 <http://purl.org/dc/terms/description> "Temperature" .
_:b6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/json-schema#NumberSchema> .
_:b6 <https://www.w3.org/2019/wot/json-schema#readOnly> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:b6 <https://www.w3.org/2019/wot/td#hasForm> _:b7 .
_:b6 <https://www.w3.org/2019/wot/td#hasForm> _:b8 .
_:b6 <https://www.w3.org/2019/wot/td#isObservable> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:b6 <https://www.w3.org/2019/wot/td#name> "Temperature" .
_:b7 <http://www.w3.org/2011/http#methodName> "GET" .
_:b7 <https://www.w3.org/2019/wot/hypermedia#forContentType> "application/json" .
_:b7 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/td#readProperty> .
_:b7 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/Temperature> .
_:b8 <https://www.w3.org/2019/wot/hypermedia#forContentType> "application/json" .
_:b8 <https://www.w3.org/2019/wot/hypermedia#forSubProtocol> "longpoll" .
_:b8 <https://www.w3.org/2019/wot/hypermedia#hasOperationType> <https://www.w3.org/2019/wot/td#observeProperty> .
_:b8 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/Temperature/observable> .
_:b9 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/saref#OnOffState> .
_:b9 <http://purl.org/dc/terms/description> "is database running" .
_:b9 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/json-schema#BooleanSchema> .
_:b9 <https://www.w3.org/2019/wot/json-schema#readOnly> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:b9 <https://www.w3.org/2019/wot/td#hasForm> _:b10 .
_:b9 <https://www.w3.org/2019/wot/td#hasForm> _:b11 .
_:b9 <https://www.w3.org/2019/wot/td#isObservable> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:b9 <https://www.w3.org/2019/wot/td#name> "databaseRunning" .
<urn:dev:ops:32473-wotdirectory-1234> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/saref#Device> .
<urn:dev:ops:32473-wotdirectory-1234> <http://purl.org/dc/terms/title> "Directory Service" .
<urn:dev:ops:32473-wotdirectory-1234> <http://www.w3.org/2003/01/geo/wgs84_pos#lat> "26.58" .
<urn:dev:ops:32473-wotdirectory-1234> <http://www.w3.org/2003/01/geo/wgs84_pos#long> "297.83" .
<urn:dev:ops:32473-wotdirectory-1234> <https://www.w3.org/2019/wot/td#hasActionAffordance> _:b0 .
<urn:dev:ops:32473-wotdirectory-1234> <https://www.w3.org/2019/wot/td#hasForm> _:b5 .
<urn:dev:ops:32473-wotdirectory-1234> <https://www.w3.org/2019/wot/td#hasPropertyAffordance> _:b6 .
<urn:dev:ops:32473-wotdirectory-1234> <https://www.w3.org/2019/wot/td#hasPropertyAffordance> _:b9 .
<urn:dev:ops:32473-wotdirectory-1234> <https://www.w3.org/2019/wot/td#hasPropertyAffordance> _:b12 .
<urn:dev:ops:32473-wotdirectory-1234> <https://www.w3.org/2019/wot/td#securityDefinitions> _:b14 .

So i thought turning the writer into an inputstream and reading it into dataset with RDFDataMgr.read would do it's job
                InputStream writerStream = new ByteArrayInputStream(writer.toString().getBytes(StandardCharsets.UTF_8));
                RDFDataMgr.read(dataset, writerStream, Lang.NQUADS);

But i get: 
Exception in thread "main" org.apache.jena.ext.com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/MurmurHash3
	at org.apache.jena.ext.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2049)
	at org.apache.jena.ext.com.google.common.cache.LocalCache.get(LocalCache.java:3962)
	at org.apache.jena.ext.com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4859)
	at org.apache.jena.atlas.lib.cache.CacheGuava.getOrFill(CacheGuava.java:58)
	at org.apache.jena.riot.lang.BlankNodeAllocatorHash.alloc(BlankNodeAllocatorHash.java:99)
	at org.apache.jena.riot.lang.LabelToNode$Alloc.alloc(LabelToNode.java:184)
	at org.apache.jena.riot.lang.LabelToNode$Alloc.alloc(LabelToNode.java:178)
	at org.apache.jena.riot.system.MapWithScope.get(MapWithScope.java:74)
	at org.apache.jena.riot.system.FactoryRDFStd.createBlankNode(FactoryRDFStd.java:92)
	at org.apache.jena.riot.system.ParserProfileStd.createBlankNode(ParserProfileStd.java:214)
	at org.apache.jena.riot.system.ParserProfileStd.create(ParserProfileStd.java:257)
	at org.apache.jena.riot.lang.LangNQuads.tokenAsNode(LangNQuads.java:119)
	at org.apache.jena.riot.lang.LangNQuads.parseOne(LangNQuads.java:69)
	at org.apache.jena.riot.lang.LangNQuads.runParser(LangNQuads.java:53)
	at org.apache.jena.riot.lang.LangBase.parse(LangBase.java:43)
	at org.apache.jena.riot.RDFParserRegistry$ReaderRIOTLang.read(RDFParserRegistry.java:180)
	at org.apache.jena.riot.RDFParser.read(RDFParser.java:358)
	at org.apache.jena.riot.RDFParser.parseNotUri(RDFParser.java:348)
	at org.apache.jena.riot.RDFParser.parse(RDFParser.java:295)
	at org.apache.jena.riot.RDFParserBuilder.parse(RDFParserBuilder.java:550)
	at org.apache.jena.riot.RDFDataMgr.parseFromInputStream(RDFDataMgr.java:721)
	at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:510)
	at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:486)
	at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:476)

any suggestions?

-----Ursprüngliche Nachricht-----
Von: Andy Seaborne <an...@apache.org> 
Gesendet: Dienstag, 27. Juli 2021 10:57
An: users@jena.apache.org
Betreff: Re: Storing ThingDescription in Dataset

It has N-Quads reader and writer, so write the RdfDataset as N-Quads to bytes or a string, and parse that. Not ideal at scale but it works; JSON-LD isn't streaming anyway.

     Andy

https://issues.apache.org/jira/browse/JENA-1948



On 27/07/2021 06:25, Philipp Leeb wrote:
> Didn't see any way to convert titanium-Dataset to jena-Dataset.
> 
> -----Ursprüngliche Nachricht-----
> Von: Andy Seaborne <an...@apache.org>
> Gesendet: Sonntag, 25. Juli 2021 18:58
> An: users@jena.apache.org
> Betreff: Re: AW: AW: AW: Storing ThingDescription in Dataset
> 
> 
> 
> On 25/07/2021 12:47, Philipp Leeb wrote:
>> Doesn't work either.
> 
> What doesn't work?
> 
>> Is there any other way of how to add my TD in JSOn-LD into my dataset?
> 
> Produce RDF - for JSON-LD 1.1, find a tool to convert it to any other RDF syntax. The JSON-LD playground will do that.
> 
> If it can do file to file, any implementation language will do. Exec a process to do the conversion.
> 
> Or
> 
> http://rdf.greggkellogg.net/distiller
> 
> which offers conversion as a service.
> 
> ----
> 
> There is a JIRA waiting for a contribution:
> 
> https://issues.apache.org/jira/browse/JENA-1948
> 
>       Andy
> 
> 
> 
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Andy Seaborne <an...@apache.org>
>> Gesendet: Sonntag, 25. Juli 2021 13:17
>> An: users@jena.apache.org
>> Betreff: Re: AW: AW: Storing ThingDescription in Dataset
>>
>> Jena prints an error.
>>
>> 2:12:36 ERROR riot            :: invalid term definition: 1.1
>>
>>
>> The playgound says it's JSON-LD 1.1 which is not (yet) supported by jsonld-java/jsonld-java/. I don't know if it is really using any 1.1 features but the @context requires it.
>>
>> Try
>> https://github.com/filip26/titanium-json-ld
>> (I've not used it)
>>
>> to convert to RDF and read the RDF.
>>
>>        Andy
>>
>> On 25/07/2021 12:00, Philipp Leeb wrote:
>>> Hi Andy,
>>>
>>> this is the JSON-LD:
>>> {"id":"urn:dev:ops:32473-wotdirectory-1234","title":"Directory
>>> Service","properties":{"Temperature":{"description":"Temperature","f
>>> o
>>> r
>>> ms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1
>>> 2
>>> 3
>>> 4/properties/Temperature","op":["readproperty"],"contentType":"appli
>>> c
>>> a
>>> tion/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:
>>> dev:ops:32473-wotdirectory-1234/properties/Temperature/observable","
>>> o
>>> p
>>> ":["observeproperty"],"subprotocol":"longpoll","contentType":"applic
>>> a
>>> t
>>> ion/json"}],"type":"number","observable":true,"readOnly":true,"@type":
>>> "saref:Temperature"},"databaseRunning":{"description":"is database 
>>> running","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-w
>>> o
>>> t
>>> directory-1234/properties/databaseRunning","op":["readproperty"],"co
>>> n
>>> t
>>> entType":"application/json","htv:methodName":"GET"},{"href":"http://
>>> l
>>> o
>>> calhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/database
>>> R
>>> u
>>> nning/observable","op":["observeproperty"],"subprotocol":"longpoll","
>>> c
>>> ontentType":"application/json"}],"type":"boolean","observable":true,"
>>> r
>>> eadOnly":true,"@type":"saref:OnOffState"},"status":{"forms":[{"href":"
>>> http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties
>>> /
>>> s
>>> tatus","op":["readproperty","writeproperty"],"contentType":"applicat
>>> i
>>> o
>>> n/json"}],"type":"string","@type":"saref:OnOffState"}},"actions":{"a
>>> d d NewResource":{"description":"Allows to register a new
>>> resource.","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473
>>> -
>>> w
>>> otdirectory-1234/actions/addNewResource{?resource}","op":["invokeact
>>> i
>>> o
>>> n"],"contentType":"application/json","htv:methodName":"POST"}],"uriV
>>> a
>>> r
>>> iables":{"resource":{"type":"string"}},"input":{"type":"object"},"ou
>>> t
>>> p
>>> ut":{"type":"string"}}},"forms":[{"href":"http://localhost:8082/urn:
>>> d
>>> e
>>> v:ops:32473-wotdirectory-1234/all/properties","op":["readallproperty"
>>> ,
>>> "readmultipleproperty"],"contentType":"application/json"}],"security":
>>> ["basic_sc"],"@type":"saref:Device","@context":["https://www.w3.org/
>>> 2
>>> 0
>>> 19/wot/td/v1",{"saref":"https://w3id.org/saref#","om":"http://www.wu
>>> r
>>> v
>>> oc.org/vocabularies/om-1.8/","ssn":"http://www.w3.org/ns/ssn/"}],"se
>>> c u rityDefinitions":{"basic_sc":{"scheme":"basic","in":"header"}}}
>>>
>>> This ist he output of JsonLdProcessor.toRdf:
>>> {
>>>      "@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"
>>>        }
>>>      } ]
>>> }
>>>
>>> And when using:
>>> InputStream in = new
>>> ByteArrayInputStream(JsonLdProcessor.toRdf(exposedThing.toJson().get
>>> B y tes(StandardCharsets.UTF_8))); Dataset dataset = 
>>> DatasetFactory.createTxnMem(); RDFDataMgr.read(dataset, in, 
>>> Lang.JSONLD); RDFDataMgr.write(System.out, dataset, Lang.JSONLD);
>>>
>>> This ist he output:
>>> { }
>>>
>>> Phil
>>>
>>>
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Andy Seaborne <an...@apache.org>
>>> Gesendet: Sonntag, 25. Juli 2021 12:52
>>> An: users@jena.apache.org
>>> Betreff: Re: AW: Storing ThingDescription in Dataset
>>>
>>> Hi Phil,
>>>
>>> That does not look like JSON-LD.
>>>
>>> JSON-LD parsing ignores anything it does not understand, not give an 
>>> error. In your code snippet, no Jena involved,
>>>
>>>        Object compact
>>>
>>> is a jsonld-data object "Dataset" (which isn't a Jena Dataset) with nothing in it.
>>>
>>> JSON-LD parsing ignores anything it does not understand, not give an error.
>>>
>>> Jena translates the output of JsonLdProcessor.toRDF to Jena objects. If there is an empty input, you get an empty output.
>>>
>>> On 25/07/2021 11:11, Philipp Leeb wrote:
>>>> 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"
>>>>         }
>>>
>>> That would be in JSON-LD:
>>>
>>> {
>>>       "@id" : "urn:dev:ops:32473-wotdirectory-1234",
>>>       "@type" : "https://w3id.org/saref#Device"
>>> }
>>>
>>> or there needs to be a @context
>>>
>>> Try it at:
>>> https://json-ld.org/playground/
>>>
>>>         Andy
>>>
>>
> 


Re: Storing ThingDescription in Dataset

Posted by Andy Seaborne <an...@apache.org>.
It has N-Quads reader and writer, so write the RdfDataset as N-Quads to 
bytes or a string, and parse that. Not ideal at scale but it works; 
JSON-LD isn't streaming anyway.

     Andy

https://issues.apache.org/jira/browse/JENA-1948



On 27/07/2021 06:25, Philipp Leeb wrote:
> Didn't see any way to convert titanium-Dataset to jena-Dataset.
> 
> -----Ursprüngliche Nachricht-----
> Von: Andy Seaborne <an...@apache.org>
> Gesendet: Sonntag, 25. Juli 2021 18:58
> An: users@jena.apache.org
> Betreff: Re: AW: AW: AW: Storing ThingDescription in Dataset
> 
> 
> 
> On 25/07/2021 12:47, Philipp Leeb wrote:
>> Doesn't work either.
> 
> What doesn't work?
> 
>> Is there any other way of how to add my TD in JSOn-LD into my dataset?
> 
> Produce RDF - for JSON-LD 1.1, find a tool to convert it to any other RDF syntax. The JSON-LD playground will do that.
> 
> If it can do file to file, any implementation language will do. Exec a process to do the conversion.
> 
> Or
> 
> http://rdf.greggkellogg.net/distiller
> 
> which offers conversion as a service.
> 
> ----
> 
> There is a JIRA waiting for a contribution:
> 
> https://issues.apache.org/jira/browse/JENA-1948
> 
>       Andy
> 
> 
> 
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Andy Seaborne <an...@apache.org>
>> Gesendet: Sonntag, 25. Juli 2021 13:17
>> An: users@jena.apache.org
>> Betreff: Re: AW: AW: Storing ThingDescription in Dataset
>>
>> Jena prints an error.
>>
>> 2:12:36 ERROR riot            :: invalid term definition: 1.1
>>
>>
>> The playgound says it's JSON-LD 1.1 which is not (yet) supported by jsonld-java/jsonld-java/. I don't know if it is really using any 1.1 features but the @context requires it.
>>
>> Try
>> https://github.com/filip26/titanium-json-ld
>> (I've not used it)
>>
>> to convert to RDF and read the RDF.
>>
>>        Andy
>>
>> On 25/07/2021 12:00, Philipp Leeb wrote:
>>> Hi Andy,
>>>
>>> this is the JSON-LD:
>>> {"id":"urn:dev:ops:32473-wotdirectory-1234","title":"Directory
>>> Service","properties":{"Temperature":{"description":"Temperature","fo
>>> r
>>> ms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-12
>>> 3
>>> 4/properties/Temperature","op":["readproperty"],"contentType":"applic
>>> a
>>> tion/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:
>>> dev:ops:32473-wotdirectory-1234/properties/Temperature/observable","o
>>> p
>>> ":["observeproperty"],"subprotocol":"longpoll","contentType":"applica
>>> t
>>> ion/json"}],"type":"number","observable":true,"readOnly":true,"@type":
>>> "saref:Temperature"},"databaseRunning":{"description":"is database
>>> running","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wo
>>> t
>>> directory-1234/properties/databaseRunning","op":["readproperty"],"con
>>> t
>>> entType":"application/json","htv:methodName":"GET"},{"href":"http://l
>>> o
>>> calhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseR
>>> u
>>> nning/observable","op":["observeproperty"],"subprotocol":"longpoll","
>>> c
>>> ontentType":"application/json"}],"type":"boolean","observable":true,"
>>> r
>>> eadOnly":true,"@type":"saref:OnOffState"},"status":{"forms":[{"href":"
>>> http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/
>>> s
>>> tatus","op":["readproperty","writeproperty"],"contentType":"applicati
>>> o
>>> n/json"}],"type":"string","@type":"saref:OnOffState"}},"actions":{"ad
>>> d NewResource":{"description":"Allows to register a new
>>> resource.","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-
>>> w
>>> otdirectory-1234/actions/addNewResource{?resource}","op":["invokeacti
>>> o
>>> n"],"contentType":"application/json","htv:methodName":"POST"}],"uriVa
>>> r
>>> iables":{"resource":{"type":"string"}},"input":{"type":"object"},"out
>>> p
>>> ut":{"type":"string"}}},"forms":[{"href":"http://localhost:8082/urn:d
>>> e
>>> v:ops:32473-wotdirectory-1234/all/properties","op":["readallproperty"
>>> ,
>>> "readmultipleproperty"],"contentType":"application/json"}],"security":
>>> ["basic_sc"],"@type":"saref:Device","@context":["https://www.w3.org/2
>>> 0
>>> 19/wot/td/v1",{"saref":"https://w3id.org/saref#","om":"http://www.wur
>>> v
>>> oc.org/vocabularies/om-1.8/","ssn":"http://www.w3.org/ns/ssn/"}],"sec
>>> u rityDefinitions":{"basic_sc":{"scheme":"basic","in":"header"}}}
>>>
>>> This ist he output of JsonLdProcessor.toRdf:
>>> {
>>>      "@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"
>>>        }
>>>      } ]
>>> }
>>>
>>> And when using:
>>> InputStream in = new
>>> ByteArrayInputStream(JsonLdProcessor.toRdf(exposedThing.toJson().getB
>>> y tes(StandardCharsets.UTF_8))); Dataset dataset =
>>> DatasetFactory.createTxnMem(); RDFDataMgr.read(dataset, in,
>>> Lang.JSONLD); RDFDataMgr.write(System.out, dataset, Lang.JSONLD);
>>>
>>> This ist he output:
>>> { }
>>>
>>> Phil
>>>
>>>
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Andy Seaborne <an...@apache.org>
>>> Gesendet: Sonntag, 25. Juli 2021 12:52
>>> An: users@jena.apache.org
>>> Betreff: Re: AW: Storing ThingDescription in Dataset
>>>
>>> Hi Phil,
>>>
>>> That does not look like JSON-LD.
>>>
>>> JSON-LD parsing ignores anything it does not understand, not give an
>>> error. In your code snippet, no Jena involved,
>>>
>>>        Object compact
>>>
>>> is a jsonld-data object "Dataset" (which isn't a Jena Dataset) with nothing in it.
>>>
>>> JSON-LD parsing ignores anything it does not understand, not give an error.
>>>
>>> Jena translates the output of JsonLdProcessor.toRDF to Jena objects. If there is an empty input, you get an empty output.
>>>
>>> On 25/07/2021 11:11, Philipp Leeb wrote:
>>>> 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"
>>>>         }
>>>
>>> That would be in JSON-LD:
>>>
>>> {
>>>       "@id" : "urn:dev:ops:32473-wotdirectory-1234",
>>>       "@type" : "https://w3id.org/saref#Device"
>>> }
>>>
>>> or there needs to be a @context
>>>
>>> Try it at:
>>> https://json-ld.org/playground/
>>>
>>>         Andy
>>>
>>
> 

AW: AW: AW: AW: Storing ThingDescription in Dataset

Posted by Philipp Leeb <p_...@t-online.de>.
Didn't see any way to convert titanium-Dataset to jena-Dataset.

-----Ursprüngliche Nachricht-----
Von: Andy Seaborne <an...@apache.org> 
Gesendet: Sonntag, 25. Juli 2021 18:58
An: users@jena.apache.org
Betreff: Re: AW: AW: AW: Storing ThingDescription in Dataset



On 25/07/2021 12:47, Philipp Leeb wrote:
> Doesn't work either.

What doesn't work?

> Is there any other way of how to add my TD in JSOn-LD into my dataset?

Produce RDF - for JSON-LD 1.1, find a tool to convert it to any other RDF syntax. The JSON-LD playground will do that.

If it can do file to file, any implementation language will do. Exec a process to do the conversion.

Or

http://rdf.greggkellogg.net/distiller

which offers conversion as a service.

----

There is a JIRA waiting for a contribution:

https://issues.apache.org/jira/browse/JENA-1948

     Andy



> 
> -----Ursprüngliche Nachricht-----
> Von: Andy Seaborne <an...@apache.org>
> Gesendet: Sonntag, 25. Juli 2021 13:17
> An: users@jena.apache.org
> Betreff: Re: AW: AW: Storing ThingDescription in Dataset
> 
> Jena prints an error.
> 
> 2:12:36 ERROR riot            :: invalid term definition: 1.1
> 
> 
> The playgound says it's JSON-LD 1.1 which is not (yet) supported by jsonld-java/jsonld-java/. I don't know if it is really using any 1.1 features but the @context requires it.
> 
> Try
> https://github.com/filip26/titanium-json-ld
> (I've not used it)
> 
> to convert to RDF and read the RDF.
> 
>       Andy
> 
> On 25/07/2021 12:00, Philipp Leeb wrote:
>> Hi Andy,
>>
>> this is the JSON-LD:
>> {"id":"urn:dev:ops:32473-wotdirectory-1234","title":"Directory
>> Service","properties":{"Temperature":{"description":"Temperature","fo
>> r
>> ms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-12
>> 3 
>> 4/properties/Temperature","op":["readproperty"],"contentType":"applic
>> a
>> tion/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:
>> dev:ops:32473-wotdirectory-1234/properties/Temperature/observable","o
>> p 
>> ":["observeproperty"],"subprotocol":"longpoll","contentType":"applica
>> t
>> ion/json"}],"type":"number","observable":true,"readOnly":true,"@type":
>> "saref:Temperature"},"databaseRunning":{"description":"is database 
>> running","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wo
>> t 
>> directory-1234/properties/databaseRunning","op":["readproperty"],"con
>> t 
>> entType":"application/json","htv:methodName":"GET"},{"href":"http://l
>> o 
>> calhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseR
>> u 
>> nning/observable","op":["observeproperty"],"subprotocol":"longpoll","
>> c 
>> ontentType":"application/json"}],"type":"boolean","observable":true,"
>> r 
>> eadOnly":true,"@type":"saref:OnOffState"},"status":{"forms":[{"href":"
>> http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/
>> s 
>> tatus","op":["readproperty","writeproperty"],"contentType":"applicati
>> o 
>> n/json"}],"type":"string","@type":"saref:OnOffState"}},"actions":{"ad
>> d NewResource":{"description":"Allows to register a new 
>> resource.","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-
>> w 
>> otdirectory-1234/actions/addNewResource{?resource}","op":["invokeacti
>> o 
>> n"],"contentType":"application/json","htv:methodName":"POST"}],"uriVa
>> r 
>> iables":{"resource":{"type":"string"}},"input":{"type":"object"},"out
>> p 
>> ut":{"type":"string"}}},"forms":[{"href":"http://localhost:8082/urn:d
>> e 
>> v:ops:32473-wotdirectory-1234/all/properties","op":["readallproperty"
>> ,
>> "readmultipleproperty"],"contentType":"application/json"}],"security":
>> ["basic_sc"],"@type":"saref:Device","@context":["https://www.w3.org/2
>> 0 
>> 19/wot/td/v1",{"saref":"https://w3id.org/saref#","om":"http://www.wur
>> v 
>> oc.org/vocabularies/om-1.8/","ssn":"http://www.w3.org/ns/ssn/"}],"sec
>> u rityDefinitions":{"basic_sc":{"scheme":"basic","in":"header"}}}
>>
>> This ist he output of JsonLdProcessor.toRdf:
>> {
>>     "@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"
>>       }
>>     } ]
>> }
>>
>> And when using:
>> InputStream in = new
>> ByteArrayInputStream(JsonLdProcessor.toRdf(exposedThing.toJson().getB
>> y tes(StandardCharsets.UTF_8))); Dataset dataset = 
>> DatasetFactory.createTxnMem(); RDFDataMgr.read(dataset, in, 
>> Lang.JSONLD); RDFDataMgr.write(System.out, dataset, Lang.JSONLD);
>>
>> This ist he output:
>> { }
>>
>> Phil
>>
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Andy Seaborne <an...@apache.org>
>> Gesendet: Sonntag, 25. Juli 2021 12:52
>> An: users@jena.apache.org
>> Betreff: Re: AW: Storing ThingDescription in Dataset
>>
>> Hi Phil,
>>
>> That does not look like JSON-LD.
>>
>> JSON-LD parsing ignores anything it does not understand, not give an 
>> error. In your code snippet, no Jena involved,
>>
>>       Object compact
>>
>> is a jsonld-data object "Dataset" (which isn't a Jena Dataset) with nothing in it.
>>
>> JSON-LD parsing ignores anything it does not understand, not give an error.
>>
>> Jena translates the output of JsonLdProcessor.toRDF to Jena objects. If there is an empty input, you get an empty output.
>>
>> On 25/07/2021 11:11, Philipp Leeb wrote:
>>> 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"
>>>        }
>>
>> That would be in JSON-LD:
>>
>> {
>>      "@id" : "urn:dev:ops:32473-wotdirectory-1234",
>>      "@type" : "https://w3id.org/saref#Device"
>> }
>>
>> or there needs to be a @context
>>
>> Try it at:
>> https://json-ld.org/playground/
>>
>>        Andy
>>
> 


Re: AW: AW: AW: Storing ThingDescription in Dataset

Posted by Andy Seaborne <an...@apache.org>.

On 25/07/2021 12:47, Philipp Leeb wrote:
> Doesn't work either.

What doesn't work?

> Is there any other way of how to add my TD in JSOn-LD into my dataset?

Produce RDF - for JSON-LD 1.1, find a tool to convert it to any other 
RDF syntax. The JSON-LD playground will do that.

If it can do file to file, any implementation language will do. Exec a 
process to do the conversion.

Or

http://rdf.greggkellogg.net/distiller

which offers conversion as a service.

----

There is a JIRA waiting for a contribution:

https://issues.apache.org/jira/browse/JENA-1948

     Andy



> 
> -----Ursprüngliche Nachricht-----
> Von: Andy Seaborne <an...@apache.org>
> Gesendet: Sonntag, 25. Juli 2021 13:17
> An: users@jena.apache.org
> Betreff: Re: AW: AW: Storing ThingDescription in Dataset
> 
> Jena prints an error.
> 
> 2:12:36 ERROR riot            :: invalid term definition: 1.1
> 
> 
> The playgound says it's JSON-LD 1.1 which is not (yet) supported by jsonld-java/jsonld-java/. I don't know if it is really using any 1.1 features but the @context requires it.
> 
> Try
> https://github.com/filip26/titanium-json-ld
> (I've not used it)
> 
> to convert to RDF and read the RDF.
> 
>       Andy
> 
> On 25/07/2021 12:00, Philipp Leeb wrote:
>> Hi Andy,
>>
>> this is the JSON-LD:
>> {"id":"urn:dev:ops:32473-wotdirectory-1234","title":"Directory
>> Service","properties":{"Temperature":{"description":"Temperature","for
>> ms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-123
>> 4/properties/Temperature","op":["readproperty"],"contentType":"applica
>> tion/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:
>> dev:ops:32473-wotdirectory-1234/properties/Temperature/observable","op
>> ":["observeproperty"],"subprotocol":"longpoll","contentType":"applicat
>> ion/json"}],"type":"number","observable":true,"readOnly":true,"@type":
>> "saref:Temperature"},"databaseRunning":{"description":"is database
>> running","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wot
>> directory-1234/properties/databaseRunning","op":["readproperty"],"cont
>> entType":"application/json","htv:methodName":"GET"},{"href":"http://lo
>> calhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseRu
>> nning/observable","op":["observeproperty"],"subprotocol":"longpoll","c
>> ontentType":"application/json"}],"type":"boolean","observable":true,"r
>> eadOnly":true,"@type":"saref:OnOffState"},"status":{"forms":[{"href":"
>> http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/s
>> tatus","op":["readproperty","writeproperty"],"contentType":"applicatio
>> n/json"}],"type":"string","@type":"saref:OnOffState"}},"actions":{"add
>> NewResource":{"description":"Allows to register a new
>> resource.","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-w
>> otdirectory-1234/actions/addNewResource{?resource}","op":["invokeactio
>> n"],"contentType":"application/json","htv:methodName":"POST"}],"uriVar
>> iables":{"resource":{"type":"string"}},"input":{"type":"object"},"outp
>> ut":{"type":"string"}}},"forms":[{"href":"http://localhost:8082/urn:de
>> v:ops:32473-wotdirectory-1234/all/properties","op":["readallproperty",
>> "readmultipleproperty"],"contentType":"application/json"}],"security":
>> ["basic_sc"],"@type":"saref:Device","@context":["https://www.w3.org/20
>> 19/wot/td/v1",{"saref":"https://w3id.org/saref#","om":"http://www.wurv
>> oc.org/vocabularies/om-1.8/","ssn":"http://www.w3.org/ns/ssn/"}],"secu
>> rityDefinitions":{"basic_sc":{"scheme":"basic","in":"header"}}}
>>
>> This ist he output of JsonLdProcessor.toRdf:
>> {
>>     "@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"
>>       }
>>     } ]
>> }
>>
>> And when using:
>> InputStream in = new
>> ByteArrayInputStream(JsonLdProcessor.toRdf(exposedThing.toJson().getBy
>> tes(StandardCharsets.UTF_8))); Dataset dataset =
>> DatasetFactory.createTxnMem(); RDFDataMgr.read(dataset, in,
>> Lang.JSONLD); RDFDataMgr.write(System.out, dataset, Lang.JSONLD);
>>
>> This ist he output:
>> { }
>>
>> Phil
>>
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Andy Seaborne <an...@apache.org>
>> Gesendet: Sonntag, 25. Juli 2021 12:52
>> An: users@jena.apache.org
>> Betreff: Re: AW: Storing ThingDescription in Dataset
>>
>> Hi Phil,
>>
>> That does not look like JSON-LD.
>>
>> JSON-LD parsing ignores anything it does not understand, not give an
>> error. In your code snippet, no Jena involved,
>>
>>       Object compact
>>
>> is a jsonld-data object "Dataset" (which isn't a Jena Dataset) with nothing in it.
>>
>> JSON-LD parsing ignores anything it does not understand, not give an error.
>>
>> Jena translates the output of JsonLdProcessor.toRDF to Jena objects. If there is an empty input, you get an empty output.
>>
>> On 25/07/2021 11:11, Philipp Leeb wrote:
>>> 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"
>>>        }
>>
>> That would be in JSON-LD:
>>
>> {
>>      "@id" : "urn:dev:ops:32473-wotdirectory-1234",
>>      "@type" : "https://w3id.org/saref#Device"
>> }
>>
>> or there needs to be a @context
>>
>> Try it at:
>> https://json-ld.org/playground/
>>
>>        Andy
>>
> 

AW: AW: AW: Storing ThingDescription in Dataset

Posted by Philipp Leeb <p_...@t-online.de>.
Doesn't work either. Is there any other way of how to add my TD in JSOn-LD into my dataset? 

-----Ursprüngliche Nachricht-----
Von: Andy Seaborne <an...@apache.org> 
Gesendet: Sonntag, 25. Juli 2021 13:17
An: users@jena.apache.org
Betreff: Re: AW: AW: Storing ThingDescription in Dataset

Jena prints an error.

2:12:36 ERROR riot            :: invalid term definition: 1.1


The playgound says it's JSON-LD 1.1 which is not (yet) supported by jsonld-java/jsonld-java/. I don't know if it is really using any 1.1 features but the @context requires it.

Try
https://github.com/filip26/titanium-json-ld
(I've not used it)

to convert to RDF and read the RDF.

     Andy

On 25/07/2021 12:00, Philipp Leeb wrote:
> Hi Andy,
> 
> this is the JSON-LD:
> {"id":"urn:dev:ops:32473-wotdirectory-1234","title":"Directory 
> Service","properties":{"Temperature":{"description":"Temperature","for
> ms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-123
> 4/properties/Temperature","op":["readproperty"],"contentType":"applica
> tion/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:
> dev:ops:32473-wotdirectory-1234/properties/Temperature/observable","op
> ":["observeproperty"],"subprotocol":"longpoll","contentType":"applicat
> ion/json"}],"type":"number","observable":true,"readOnly":true,"@type":
> "saref:Temperature"},"databaseRunning":{"description":"is database 
> running","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wot
> directory-1234/properties/databaseRunning","op":["readproperty"],"cont
> entType":"application/json","htv:methodName":"GET"},{"href":"http://lo
> calhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseRu
> nning/observable","op":["observeproperty"],"subprotocol":"longpoll","c
> ontentType":"application/json"}],"type":"boolean","observable":true,"r
> eadOnly":true,"@type":"saref:OnOffState"},"status":{"forms":[{"href":"
> http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/s
> tatus","op":["readproperty","writeproperty"],"contentType":"applicatio
> n/json"}],"type":"string","@type":"saref:OnOffState"}},"actions":{"add
> NewResource":{"description":"Allows to register a new 
> resource.","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-w
> otdirectory-1234/actions/addNewResource{?resource}","op":["invokeactio
> n"],"contentType":"application/json","htv:methodName":"POST"}],"uriVar
> iables":{"resource":{"type":"string"}},"input":{"type":"object"},"outp
> ut":{"type":"string"}}},"forms":[{"href":"http://localhost:8082/urn:de
> v:ops:32473-wotdirectory-1234/all/properties","op":["readallproperty",
> "readmultipleproperty"],"contentType":"application/json"}],"security":
> ["basic_sc"],"@type":"saref:Device","@context":["https://www.w3.org/20
> 19/wot/td/v1",{"saref":"https://w3id.org/saref#","om":"http://www.wurv
> oc.org/vocabularies/om-1.8/","ssn":"http://www.w3.org/ns/ssn/"}],"secu
> rityDefinitions":{"basic_sc":{"scheme":"basic","in":"header"}}}
> 
> This ist he output of JsonLdProcessor.toRdf:
> {
>    "@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"
>      }
>    } ]
> }
> 
> And when using:
> InputStream in = new 
> ByteArrayInputStream(JsonLdProcessor.toRdf(exposedThing.toJson().getBy
> tes(StandardCharsets.UTF_8))); Dataset dataset = 
> DatasetFactory.createTxnMem(); RDFDataMgr.read(dataset, in, 
> Lang.JSONLD); RDFDataMgr.write(System.out, dataset, Lang.JSONLD);
> 
> This ist he output:
> { }
> 
> Phil
> 
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Andy Seaborne <an...@apache.org>
> Gesendet: Sonntag, 25. Juli 2021 12:52
> An: users@jena.apache.org
> Betreff: Re: AW: Storing ThingDescription in Dataset
> 
> Hi Phil,
> 
> That does not look like JSON-LD.
> 
> JSON-LD parsing ignores anything it does not understand, not give an 
> error. In your code snippet, no Jena involved,
> 
>      Object compact
> 
> is a jsonld-data object "Dataset" (which isn't a Jena Dataset) with nothing in it.
> 
> JSON-LD parsing ignores anything it does not understand, not give an error.
> 
> Jena translates the output of JsonLdProcessor.toRDF to Jena objects. If there is an empty input, you get an empty output.
> 
> On 25/07/2021 11:11, Philipp Leeb wrote:
>> 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"
>>       }
> 
> That would be in JSON-LD:
> 
> {
>     "@id" : "urn:dev:ops:32473-wotdirectory-1234",
>     "@type" : "https://w3id.org/saref#Device"
> }
> 
> or there needs to be a @context
> 
> Try it at:
> https://json-ld.org/playground/
> 
>       Andy
> 


Re: AW: AW: Storing ThingDescription in Dataset

Posted by Andy Seaborne <an...@apache.org>.
Jena prints an error.

2:12:36 ERROR riot            :: invalid term definition: 1.1


The playgound says it's JSON-LD 1.1 which is not (yet) supported by 
jsonld-java/jsonld-java/. I don't know if it is really using any 1.1 
features but the @context requires it.

Try
https://github.com/filip26/titanium-json-ld
(I've not used it)

to convert to RDF and read the RDF.

     Andy

On 25/07/2021 12:00, Philipp Leeb wrote:
> Hi Andy,
> 
> this is the JSON-LD:
> {"id":"urn:dev:ops:32473-wotdirectory-1234","title":"Directory Service","properties":{"Temperature":{"description":"Temperature","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/Temperature","op":["readproperty"],"contentType":"application/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/Temperature/observable","op":["observeproperty"],"subprotocol":"longpoll","contentType":"application/json"}],"type":"number","observable":true,"readOnly":true,"@type":"saref:Temperature"},"databaseRunning":{"description":"is database running","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseRunning","op":["readproperty"],"contentType":"application/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseRunning/observable","op":["observeproperty"],"subprotocol":"longpoll","contentType":"application/json"}],"type":"boolean","observable":true,"readOnly":true,"@type":"saref:OnOffState"},"status":{"forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/status","op":["readproperty","writeproperty"],"contentType":"application/json"}],"type":"string","@type":"saref:OnOffState"}},"actions":{"addNewResource":{"description":"Allows to register a new resource.","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/actions/addNewResource{?resource}","op":["invokeaction"],"contentType":"application/json","htv:methodName":"POST"}],"uriVariables":{"resource":{"type":"string"}},"input":{"type":"object"},"output":{"type":"string"}}},"forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/all/properties","op":["readallproperty","readmultipleproperty"],"contentType":"application/json"}],"security":["basic_sc"],"@type":"saref:Device","@context":["https://www.w3.org/2019/wot/td/v1",{"saref":"https://w3id.org/saref#","om":"http://www.wurvoc.org/vocabularies/om-1.8/","ssn":"http://www.w3.org/ns/ssn/"}],"securityDefinitions":{"basic_sc":{"scheme":"basic","in":"header"}}}
> 
> This ist he output of JsonLdProcessor.toRdf:
> {
>    "@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"
>      }
>    } ]
> }
> 
> And when using:
> InputStream in = new ByteArrayInputStream(JsonLdProcessor.toRdf(exposedThing.toJson().getBytes(StandardCharsets.UTF_8)));
> Dataset dataset = DatasetFactory.createTxnMem();
> RDFDataMgr.read(dataset, in, Lang.JSONLD);
> RDFDataMgr.write(System.out, dataset, Lang.JSONLD);
> 
> This ist he output:
> { }
> 
> Phil
> 
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Andy Seaborne <an...@apache.org>
> Gesendet: Sonntag, 25. Juli 2021 12:52
> An: users@jena.apache.org
> Betreff: Re: AW: Storing ThingDescription in Dataset
> 
> Hi Phil,
> 
> That does not look like JSON-LD.
> 
> JSON-LD parsing ignores anything it does not understand, not give an error. In your code snippet, no Jena involved,
> 
>      Object compact
> 
> is a jsonld-data object "Dataset" (which isn't a Jena Dataset) with nothing in it.
> 
> JSON-LD parsing ignores anything it does not understand, not give an error.
> 
> Jena translates the output of JsonLdProcessor.toRDF to Jena objects. If there is an empty input, you get an empty output.
> 
> On 25/07/2021 11:11, Philipp Leeb wrote:
>> 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"
>>       }
> 
> That would be in JSON-LD:
> 
> {
>     "@id" : "urn:dev:ops:32473-wotdirectory-1234",
>     "@type" : "https://w3id.org/saref#Device"
> }
> 
> or there needs to be a @context
> 
> Try it at:
> https://json-ld.org/playground/
> 
>       Andy
> 

AW: AW: Storing ThingDescription in Dataset

Posted by Philipp Leeb <p_...@t-online.de>.
Hi Andy,

this is the JSON-LD:
{"id":"urn:dev:ops:32473-wotdirectory-1234","title":"Directory Service","properties":{"Temperature":{"description":"Temperature","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/Temperature","op":["readproperty"],"contentType":"application/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/Temperature/observable","op":["observeproperty"],"subprotocol":"longpoll","contentType":"application/json"}],"type":"number","observable":true,"readOnly":true,"@type":"saref:Temperature"},"databaseRunning":{"description":"is database running","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseRunning","op":["readproperty"],"contentType":"application/json","htv:methodName":"GET"},{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/databaseRunning/observable","op":["observeproperty"],"subprotocol":"longpoll","contentType":"application/json"}],"type":"boolean","observable":true,"readOnly":true,"@type":"saref:OnOffState"},"status":{"forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/properties/status","op":["readproperty","writeproperty"],"contentType":"application/json"}],"type":"string","@type":"saref:OnOffState"}},"actions":{"addNewResource":{"description":"Allows to register a new resource.","forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/actions/addNewResource{?resource}","op":["invokeaction"],"contentType":"application/json","htv:methodName":"POST"}],"uriVariables":{"resource":{"type":"string"}},"input":{"type":"object"},"output":{"type":"string"}}},"forms":[{"href":"http://localhost:8082/urn:dev:ops:32473-wotdirectory-1234/all/properties","op":["readallproperty","readmultipleproperty"],"contentType":"application/json"}],"security":["basic_sc"],"@type":"saref:Device","@context":["https://www.w3.org/2019/wot/td/v1",{"saref":"https://w3id.org/saref#","om":"http://www.wurvoc.org/vocabularies/om-1.8/","ssn":"http://www.w3.org/ns/ssn/"}],"securityDefinitions":{"basic_sc":{"scheme":"basic","in":"header"}}}

This ist he output of JsonLdProcessor.toRdf:
{
  "@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"
    }
  } ]
}

And when using:
InputStream in = new ByteArrayInputStream(JsonLdProcessor.toRdf(exposedThing.toJson().getBytes(StandardCharsets.UTF_8)));
Dataset dataset = DatasetFactory.createTxnMem();
RDFDataMgr.read(dataset, in, Lang.JSONLD);
RDFDataMgr.write(System.out, dataset, Lang.JSONLD);

This ist he output:
{ }

Phil




-----Ursprüngliche Nachricht-----
Von: Andy Seaborne <an...@apache.org> 
Gesendet: Sonntag, 25. Juli 2021 12:52
An: users@jena.apache.org
Betreff: Re: AW: Storing ThingDescription in Dataset

Hi Phil,

That does not look like JSON-LD.

JSON-LD parsing ignores anything it does not understand, not give an error. In your code snippet, no Jena involved,

    Object compact

is a jsonld-data object "Dataset" (which isn't a Jena Dataset) with nothing in it.

JSON-LD parsing ignores anything it does not understand, not give an error.

Jena translates the output of JsonLdProcessor.toRDF to Jena objects. If there is an empty input, you get an empty output.

On 25/07/2021 11:11, Philipp Leeb wrote:
> 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"
>      }

That would be in JSON-LD:

{
   "@id" : "urn:dev:ops:32473-wotdirectory-1234",
   "@type" : "https://w3id.org/saref#Device"
}

or there needs to be a @context

Try it at:
https://json-ld.org/playground/

     Andy


Re: AW: Storing ThingDescription in Dataset

Posted by Andy Seaborne <an...@apache.org>.
Hi Phil,

That does not look like JSON-LD.

JSON-LD parsing ignores anything it does not understand, not give an 
error. In your code snippet, no Jena involved,

    Object compact

is a jsonld-data object "Dataset" (which isn't a Jena Dataset) with 
nothing in it.

JSON-LD parsing ignores anything it does not understand, not give an error.

Jena translates the output of JsonLdProcessor.toRDF to Jena objects. If 
there is an empty input, you get an empty output.

On 25/07/2021 11:11, Philipp Leeb wrote:
> 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"
>      }

That would be in JSON-LD:

{
   "@id" : "urn:dev:ops:32473-wotdirectory-1234",
   "@type" : "https://w3id.org/saref#Device"
}

or there needs to be a @context

Try it at:
https://json-ld.org/playground/

     Andy

AW: Storing ThingDescription in Dataset

Posted by Philipp Leeb <p_...@t-online.de>.
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 <an...@apache.org> 
Gesendet: Sonntag, 25. Juli 2021 11:59
An: users@jena.apache.org
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
> 
> 


Re: Storing ThingDescription in Dataset

Posted by Andy Seaborne <an...@apache.org>.
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.UTF_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
> 
>