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 <[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