Subject: json-ld (part 1 of 3)
- note: originally emailed 05/28/2014 and sanitized for public consumption
- sidenote: posting here so i can lead people here whenever they ask me about this stuff...
- series: part 2 & part 3
[Boss,]
Over the weekend, I looked into more about the JSON-LD stuff -- I get what it's doing -- but, we [are not] building a social network nor do we want dynamically generated 'queries' in areas that should be 'sanitized' (input validated, [...] etc.).
That said, the inventor of JSON-LD complained about a lot of things and the reason for creating JSON-LD (but hated on quad store a.k.a. named-graph).
I'll getting to the "sparkle" part in just a bit. But, here's a sneak peek:
Anyways, if you ever read any of Microsoft's HTML exporter from their Word app you would see things like:
<html xmlns:v="urn:schemas-microsoft-com:vml"See all those xmlns: items?
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">
<head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><title></title>
<style>
...
Those are never used outside of your work, except for tracking purposes outside of your company. To "help" them figure out what you're document "means" instead of just a bunch of "content". This is what is known as the RDF annotation. RDF stands for Resource Description Format -- basically meta data for your content.
So, going back to JSON-LD: they want to transform something like this:
- http://XYZ/ajax/api/path.php?user=name1
- That would return something like this:
- { "result" : "pass", "balance" : "111111" }
- To returning something like this:
{ "@context": { "name": "http://xmlns.com/foaf/0.1/name", "balance": "http://json-ld-server/rdf/0.1/name", }, "name": "X name1", "balance": "111111" }
- In other words, you need to describe what the data is -- instead of just dumping it.
- Do note, this will also mean there's no stopping them from changing the simple ajax request of:
- http://XYZ/ajax/api/path.php?user=name1
- To something more convoluted like:
- POST: http://json-ld-server/
- POSTDATA:
{ "@context": { "name": "http://xmlns.com/foaf/0.1/name", "query": "http://json-ld-server/rdf/0.1/query", }, "name": "X name1", "query": "balance" }
- Again, all meant for systems outside of ours to help them understand our system (i.e. route around/through our data)...
Finally, SPARQL (pronounced -- sparkle) can be seen like this: S(PAR)QL -- which stands for: SPARQL Protocol and RDF Query Language
- This allows you to do all things SQL (CREATE, INSERT, UPDATE, DROP, etc.) with this terse way of representing all of the data (highly error prone if written by humans -- this will need to be generated with tools just to be safe)
- The named-graphic link above earlier, shows some examples -- but it's still means this needs someone to write the query... this is all duplicated work...