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 <[email protected]> 
Gesendet: Sonntag, 25. Juli 2021 13:17
An: [email protected]
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 <[email protected]>
> Gesendet: Sonntag, 25. Juli 2021 12:52
> An: [email protected]
> 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
> 

Reply via email to