- From: David Janes <davidjanes@davidjanes.com>
- Date: Thu, 21 Jan 2016 16:49:58 -0500
- To: "public-web-of-." <public-web-of-things@w3.org>
- Message-ID: <CACp1KyP1SqEjdj+QccN36nwNBN=OUoZj3HoxPBPDUviSfw-MTA@mail.gmail.com>
Although JSON is readable, the approach y'all taking with using JSON as an _authoring_ language is fundamentally flawed. JSON is readable, but it's still unsuited for most domain specific applications. Instead, IOTDB has (after several failed ideas [1]) adopted the _little language_ [2] approach called IoTQL [3]. Here for example is a model for a Hue (or Hue-like) Light [4] CREATE MODEL HueLight WITH schema:name = "Hue Light", schema:description = "Philips Hue colored light", iot:facet = iot-facet:lighting ATTRIBUTE *on* WITH schema:name = "on", *iot:purpose = iot-purpose:on,* iot:type = iot:type.boolean ATTRIBUTE color WITH schema:name = "color", iot:purpose = iot-purpose:color, iot:type = iot:type.string, iot:format = iot:format.color This is trivially human readable, and easy enough to write, all the QNames resolving to sensible values, e.g. we know what the attribute called "on" does by just looking at it *iot:purpose* https://iotdb.org/pub/iot#on *iot-purpose:on* https://iotdb.org/pub/iot-purpose#on This compiles to JSON-LD, which is difficult to properly write but easily understood by consumers. You can see the JSON-LD for this model here [5]. Finally, if you need to get to triples this all reads quite well also (though I wouldn't recommend it over the JSON-LD version) <file:///hue-light#color> <http://schema.org/name> "color" . <file:///hue-light#color> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://iotdb.org/pub/iot#Attribute> . <file:///hue-light#color> <https://iotdb.org/pub/iot#actuator> "true"^^< http://www.w3.org/2001/XMLSchema#boolean> . <file:///hue-light#color> <https://iotdb.org/pub/iot#format> <https://iotdb.org/pub/iot#format.color> . <file:///hue-light#color> <https://iotdb.org/pub/iot#purpose> <https://iotdb.org/pub/iot-purpose#color> . <file:///hue-light#color> <https://iotdb.org/pub/iot#read> "true"^^< http://www.w3.org/2001/XMLSchema#boolean> . <file:///hue-light#color> <https://iotdb.org/pub/iot#sensor> "true"^^< http://www.w3.org/2001/XMLSchema#boolean> . <file:///hue-light#color> <https://iotdb.org/pub/iot#type> <https://iotdb.org/pub/iot#type.string> . <file:///hue-light#color> <https://iotdb.org/pub/iot#write> "true"^^< http://www.w3.org/2001/XMLSchema#boolean> . *<file:///hue-light#on>* * <http://schema.org/name <http://schema.org/name>> "on" .* <file:///hue-light#on> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://iotdb.org/pub/iot#Attribute> . <file:///hue-light#on> <https://iotdb.org/pub/iot#actuator> "true"^^< http://www.w3.org/2001/XMLSchema#boolean> . *<file:///hue-light#on>* * <https://iotdb.org/pub/iot#purpose <https://iotdb.org/pub/iot#purpose>>* * <https://iotdb.org/pub/iot-purpose#on <https://iotdb.org/pub/iot-purpose#on>> .* <file:///hue-light#on> <https://iotdb.org/pub/iot#read> "true"^^< http://www.w3.org/2001/XMLSchema#boolean> . <file:///hue-light#on> <https://iotdb.org/pub/iot#sensor> "true"^^< http://www.w3.org/2001/XMLSchema#boolean> . <file:///hue-light#on> <https://iotdb.org/pub/iot#type> <https://iotdb.org/pub/iot#type.boolean> . <file:///hue-light#on> <https://iotdb.org/pub/iot#write> "true"^^< http://www.w3.org/2001/XMLSchema#boolean> . <file:///hue-light> <http://schema.org/description> "Philips Hue colored light" . <file:///hue-light> <http://schema.org/name> "Hue Light" . <file:///hue-light> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://iotdb.org/pub/iot#Model> . <file:///hue-light> <https://iotdb.org/pub/iot#attribute> <file:///hue-light#color> . *<file:///hue-light>* * <https://iotdb.org/pub/iot#attribute <https://iotdb.org/pub/iot#attribute>>* * <file:///hue-light#on> .* <file:///hue-light> <https://iotdb.org/pub/iot#facet> <https://iotdb.org/pub/iot-facet#lighting> . My apologies if any of this comes out fuzzy: it's authored in GMail with a fair bit of formatting. The links below have the original sources. References: [1] using an HTML-based editor; writing in natively JSON; writing in Javascript that compiles to JSON. [2] https://en.wikipedia.org/wiki/Domain-specific_language [3] https://github.com/dpjanes/iotdb-iotql [4] https://github.com/dpjanes/homestar-hue/blob/master/models/HueLight.iotql [5] https://github.com/dpjanes/homestar-hue/blob/master/models/HueLight.json Regards, etc... David
Received on Thursday, 21 January 2016 21:50:48 UTC