@node-wot/td-tools
TypeScript icon, indicating that this package has built-in type declarations

0.8.12 • Public • Published

TD (Thing Description) tools of node-wot

Current Maintainer(s): @danielpeintner @relu91

Getting Started

In the following example it is shown how td-tools of node-wot can be used.

Prerequisites

  • npm install @node-wot/td-tools

Example

The example parses a TD and also serializes yet another newly created TD.

node example.js

// example.js
const TDTools = require("@node-wot/td-tools");
const { Thing } = require("@node-wot/td-tools");

// parse TD
const tdString = JSON.stringify({
    id : "123",
    title: "MyThing"
});
const dd = TDTools.parseTD(tdString);
console.log("**** PARSED TD ****");
console.log(dd);
console.log("****");


// init Thing and serialize to TD
const thing = new Thing();
thing.id = "789";
thing["@type"] = "Thing";
thing.support = "foo@example.com"
thing.properties = {
    "myProp" : {
        type: "integer"
    }
}
const tdString2 = TDTools.serializeTD(thing);
console.log("**** SERIALIZED TD ****");
console.log(tdString2);
console.log("****");

More Details

See https://github.com/eclipse-thingweb/node-wot/

Readme

Keywords

none

Package Sidebar

Install

npm i @node-wot/td-tools

Weekly Downloads

159

Version

0.8.12

License

EPL-2.0 OR W3C-20150513

Unpacked Size

312 kB

Total Files

31

Last publish

Collaborators

  • egeko
  • mkovatsc
  • danielpeintner
  • sebastiankb
  • h0ru5