{"id":13499855,"url":"https://github.com/oeg-upm/wot-jtd","last_synced_at":"2025-12-26T23:44:29.043Z","repository":{"id":46036755,"uuid":"322325313","full_name":"oeg-upm/wot-jtd","owner":"oeg-upm","description":"Java API for Thing Descriptions of the Web of Things","archived":false,"fork":false,"pushed_at":"2021-11-18T14:17:21.000Z","size":342,"stargazers_count":12,"open_issues_count":2,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-01-25T04:54:25.238Z","etag":null,"topics":["iot","java-api","serialisation","wot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oeg-upm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-17T14:49:27.000Z","updated_at":"2023-02-08T15:54:31.000Z","dependencies_parsed_at":"2022-09-02T14:30:54.638Z","dependency_job_id":null,"html_url":"https://github.com/oeg-upm/wot-jtd","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeg-upm%2Fwot-jtd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeg-upm%2Fwot-jtd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeg-upm%2Fwot-jtd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeg-upm%2Fwot-jtd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oeg-upm","download_url":"https://codeload.github.com/oeg-upm/wot-jtd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246145012,"owners_count":20730494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iot","java-api","serialisation","wot"],"created_at":"2024-07-31T22:00:44.454Z","updated_at":"2025-12-26T23:44:28.990Z","avatar_url":"https://github.com/oeg-upm.png","language":"Java","funding_links":[],"categories":["Section"],"sub_categories":["Tools"],"readme":"# Java API for Thing Descriptions of WoT (JDTs)\n[![Version](https://img.shields.io/badge/Version-0.2.2-orange)](https://github.com/oeg-upm/wot-jtd/releases)] [![Maven Central](https://img.shields.io/badge/Maven%20Central-v0.2.2-green)](https://search.maven.org/search?q=g:%22es.upm.fi.oeg%22%20AND%20a:%22wot-jtd%22) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![GitHub stars](https://img.shields.io/github/stars/Naereen/StrapDown.js.svg?style=social\u0026label=Star\u0026maxAge=2592000)](https://github.com/oeg-upm/wot-jtd/stargazers)\n\nThe JDT is an ORM implementation of the current [Thing Description](https://www.w3.org/TR/wot-thing-description/) model standardised by the [W3C Web of Things group](https://www.w3.org/WoT/). The current features are:\n * Serialise:\n\t * Serialise any Thing Description as a Java Object, i.e., a JDT\n\t * Serialise a JDT from a JSON-LD framed document\n\t * Serialise a JDT from a set of RDF triples\n * Round trip-translation:\n\t * Translate from a JSON-LD framed document into a set of equivalent RDF triples\n\t * Translate a set of RDF triples into its equivalent JSON-LD framed document\n * Validation \n\t * Validate a JTD using [SHACL shapes](https://www.w3.org/TR/shacl/)\n\t * Validate a JTD using [JSON schema](https://json-schema.org/)  **(coming soon)**\n\t * Validate a JTD according to the [restrictions specified in the standard](https://www.w3.org/TR/wot-thing-description/)  **(coming soon)**\n\n\nIf you have any feedback or feature suggestion, please let us know posting an issue with the label \u003cspan style=\"color:#EFA914\"\u003e**feedback**\u003c/span\u003e\n\n## Table of contents\n\n* Installation\n* Model\n* Usage:\n    * Serialisation of JTDs:\n\t\t* From JSON-LD framed document\n\t\t* From RDF triples\n\t* Deserialisation of JTDs:\n\t\t* To JSON-LD framed\n\t\t* To RDF triples\n\t* JDT validation: \n\t\t* Using SHACL shapes\n\t\t* Using JSON schema (**coming soon**)\n\t\t* Using restrictions in the model (**coming soon**)\n\n\n\n## Installation:\nImport the JDTs library as a maven dependency, **be sure to specify the latest version**:\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ees.upm.fi.oeg\u003c/groupId\u003e\n  \u003cartifactId\u003ewot-jtd\u003c/artifactId\u003e\n  \u003cversion\u003e0.2.2\u003c/version\u003e\n\u003c/dependency\u003e\n``` \n\nAlternatively, the dependency can be installed manually. First, download the latest jar from the [releases section](), and then install the dependency as follows (**be sure to specify the latest version**):\n````\nmvn install:install-file -Dfile=wot-jtd.jar -DgroupId=es.upm.fi.oeg -DartifactId=wot-jtd -Dversion=0.2.2 -Dpackaging=jar\n````\n\nCheck our [Maven Central Repository page](https://search.maven.org/artifact/es.upm.fi.oeg/wot-jtd/0.2.2/jar) to discover other installation options like Gradle Groovy or Kotlin, Scala, and others. \n\n## Model\n\nThe JDT library implement as Java objects the whole model, and its restrictions, defined in the [Thing Description standard](https://www.w3.org/TR/wot-thing-description/). The overview of the model is the following:\n\n![Thing Description model](https://www.w3.org/TR/wot-thing-description/visualization/td.png)\n\n\n## Usage\n\n### Serialisation of JTDs:\n\nFor the next examples, let's assume the following java variables containing the same Thing description:\n````\nString strJsonTD = \"{ \\\"@context\\\": \\\"https://www.w3.org/2019/wot/td/v1\\\",\\n\" +\n\" \\\"id\\\": \\\"urn:dev:ops:32473-WoTLamp-1234\\\",\\n\" +\n\" \\\"title\\\": \\\"MyLampThing\\\",\\n\" +\n\" \\\"securityDefinitions\\\": { \\\"nosec_sc\\\": { \\\"scheme\\\": \\\"nosec\\\" }},\\n\" +\n\" \\\"security\\\": \\\"nosec_sc\\\",\\n\" +\n\" \\\"properties\\\": {\\n\" +\n\"     \\\"status\\\": {\\n\" +\n\"         \\\"type\\\": \\\"string\\\",\\n\" +\n\"         \\\"forms\\\": [{\\\"href\\\": \\\"https://mylamp.example.com/status\\\"}]\\n\" +\n\"     }\\n\" +\n\" }\\n\" +\n\"}\";\n````\n\n````\nModel modelTD = ModelFactory.createDefaultModel();\nString strRdfTD = \"@prefix dc: \u003chttp://purl.org/dc/terms/\u003e .\\n\" +\n\"@prefix td: \u003chttps://www.w3.org/2019/wot/td#\u003e .\\n\" +\n\"@prefix jsonschema: \u003chttps://www.w3.org/2019/wot/json-schema#\u003e .\\n\" +\n\"@prefix hctl: \u003chttps://www.w3.org/2019/wot/hypermedia#\u003e .\\n\" +\n\"\\n\" +\n\"\u003curn:dev:ops:32473-WoTLamp-1234\u003e\\n\" +\n\"  dc:title \\\"MyLampThing\\\" ;\\n\" +\n\"  td:hasPropertyAffordance [\\n\" +\n\"      a \u003chttps://www.w3.org/2019/wot/json-schema#StringSchema\u003e ;\\n\" +\n\"      jsonschema:propertyName \\\"status\\\" ;\\n\" +\n\"      td:hasForm [ hctl:hasTarget \u003chttps://mylamp.example.com/status\u003e ]\\n\" +\n\"  ] ;\\n\" +\n\"  td:hasSecurityConfiguration \u003chttps://json-ld.org/playground/nosec_sc\u003e ;\\n\" +\n\"  td:securityDefinitions [ td:scheme \\\"nosec\\\" ] .\";\n\n##### Read the string variable into the jena model\nmodelTD.read(new ByteArrayInputStream(strRdfTD.getBytes()), null, \"Turtle\");\n````\n\n\n\nThe following serialisation operations consists of building a JTD object Thing from either a JSON-LD framed representation or a set of RDF triples. \n##### From JSON-LD framed document\n\n````\nJsonObject jsonTD = JTD.parseJson(strJsonTD);\nThing thing = Thing.fromJson(jsonTD);\nthing = (Thing) JTD.instantiateFromJson(jsonTD, Thing.class); # Alternativelly\n````\nNotice that using the method `JTD.instantiateFromJson(jsonTD, Thing.class)` any other class from the model can be serialised.\n\n##### From RDF triples\nIn order to build a JTD object from a set of RDF triples there are two main methods:\n##### A) Build a list of JTDs in case that the triples contain more than one Thing resource.\n`````\nList\u003cThing\u003e things = fromRDF(modelTD)\n`````\n##### B) Build a unique JTDs providing the RDF  resource URI. \n`````\nThing thing = fromRDF(modelTD, \"urn:dev:ops:32473-WoTLamp-1234\")\n`````\n\n### Deserialisation of JTDs:\n\n##### To JSON-LD framed\n````\nJsonObject jsonTD = thing.toJson()\njsonTD = JTD.toJson(thing) # Alternativelly\n````\nNotice that using the method `JTD.toJson(thing)` any other class from the model can be deserialised.\n\n##### To RDF triples\n\n````\nModel modelTD = JTD.toRDF(thing)\n # Alternativelly\nJsonObject jsonTD = thing.toJson()\nmodelTD = JTD.toRDF(jsonTD)\n````\n\nNotice that using the method alternative `JTD.toRDF(jsonTD)` there is actually no need to serialise the JSON-LD framed `jsonTD` as a Java object, it can be directly translated into RDF.\n\n\n### JDT validation\n\n##### Using SHACL shapes\nCurrently, the Web of Things provides [an official SHACL shape document](https://github.com/w3c/wot-thing-description/blob/main/validation/td-validation.ttl) for validating Thing Descriptions. This shape, or any other, can be used to validate a JTD Thing as follows:\n\n````\nString shapesURI = \"https://raw.githubusercontent.com/w3c/wot-thing-description/main/validation/td-validation.ttl\"\nModel shapesGraph = RDFDataMgr.loadModel(shapesURI, Lang.TURTLE);\nValidationReport shapeReport = JTD.validateWithShape(thing, shapesGraph);\n````\n\n##### Using JSON schema (*comming soon*)\n##### Using restrictions in the model (*comming soon*)\n\n\n### Support or Contact\nWoT-JTD was created by [Andrea Cimmino](https://scholar.google.es/citations?user=_6U9WMcAAAAJ\u0026hl=es\u0026oi=ao) (cimmino@fi.upm.es) and [Raúl García Castro](http://garcia-castro.com/) (rgarcia@fi.upm.es) at the [Universidad Politécnica de Madrid](https://www.upm.es/) in the research group [Ontology Engineering Group](https://oeg.fi.upm.es/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeg-upm%2Fwot-jtd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foeg-upm%2Fwot-jtd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeg-upm%2Fwot-jtd/lists"}