JSON-LD
jbenet opened this issue · comments
Actually, it's probably worth considering the benefits of expressing Finitio directly in JSON-LD. Basically, make a one-to-one converter between Finitio and a JSON-LD representation of Finitio. That way websites could leverage Finitio directly in JSON APIs.
I had deeper look at JSON-LD. I'm not sure to understand what "expressing Finitio in JSON-LD" actually means. Finitio is a type system, at class level say. JSON-LD is a way to encode hyperlinks among multiple JSON documents, at instance level I would tempted to say.
While there are definitely synergetic links to be investigated, I'm not so sure to understand what there are exactly. Maybe an example/use-case would help here.
What I mean is that you can express a Finitio document in JSON-LD.
Finitio
Temp = <celsius> Real( f | f >= 33.0 and f <= 45.0 )
{
patient : {
id : Uuid,
name : String( s | s.size > 0 ),
dob : Date( d | alive: d.year > 1890 ),
},
symptoms : [ String( s | s.size > 0 ) ],
temperature : Temp
}
JSON-LD version would be something like:
{
"@context": "http://finitio.io/schemas/finitio-doc.jsonld",
"patient": {
"id": {
"@type": "Uuid"
},
"name": {
"@type": "String",
"finitio": "String( s | s.size > 0)"
},
"dob": {
"@type": "Date",
"finitio": "Date( d | alive: d.year > 1890 )"
},
},
"symptoms" : [ {
"@type": "Symptom",
"finitio": "String( s | s.size > 0 )"
} ],
"temperature" : {
"@type": "Temp",
"finitio": "<celsius> Real( f | f >= 33.0 and f <= 45.0 )"
}
Not really sure how this would look. The goal is to make types expressed in finitio available to apps via JSON-LD. If we had a 1-to-1 mapping, this could work.
See JSON-LD schema examples at schema.org. e.g. bottom of http://schema.org/Person
Worth mentioning that since most APIs use JSON right now, JSON-LD is a very easy transition. So, making Finitio transpilable to JSON-LD would ease adoption. Think of writing finitio schemas for an API and then publishing them to a JSON-LD endpoint with one tool.
Ok, I better understand your motivation. I'll have to work on the details.
Still, I'm not sure to understand the subtle difference between "converting a Finitio system to JSON-LD" and "converting a Finitio system a JSON data representation of what it captures". In other words, what is the linked data exactly here?