Skip to content

Instantly share code, notes, and snippets.

@veganstraightedge
Last active May 27, 2018 15:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veganstraightedge/6179849 to your computer and use it in GitHub Desktop.
Save veganstraightedge/6179849 to your computer and use it in GitHub Desktop.
http://json-ld.org claims to be a format of JSON to organize and link data on the web. HTML already provides a way to link data with the <a href> tag and microformats (in this case h-card and xfn) already provide a way to add additional machine readable semantics.
{
"@context": "http://json-ld.org/contexts/person.jsonld",
"@id": "http://dbpedia.org/resource/John_Lennon",
"name": "John Lennon",
"born": "1940-10-09",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}
<div class="h-card">
<a href="http://dbpedia.org/resource/John_Lennon" class="u-url u-uid p-name">John Lennon</a>
was born on
<time class="dt-bday" datetime="1940-10-09">October 9<sup>th</sup>, 1940</time>
and was married to
<a rel="spouse" href="http://dbpedia.org/resource/Cynthia_Lennon">Cynthia Lennon</a>.
</div>
<div class="h-card">
<a href="http://dbpedia.org/resource/John_Lennon" class="u-url u-uid p-name">John Lennon</a>
<time class="dt-bday">1940-10-09</time>
<a rel="spouse" href="http://dbpedia.org/resource/Cynthia_Lennon">Cynthia Lennon</a>
</div>
@veganstraightedge
Copy link
Author

@msporny "isn't the best way" doesn't count as a good argument. Try again. ;)

@LeifW
Copy link

LeifW commented Aug 10, 2013

JSON is a common data format. The data parsed from Microformats 2 is described in terms of its JSON representation: http://microformats.org/wiki/microformats-2-parsing. Data is transformed between a variety of representations all the time - such as for this web page you're now reading, which is generated by interpolating the appropriate data from a database into the HTML. If people want a JSON view of my data without the HTML that they can use their JSON parsers / databases on, I don't see the harm in accommodating them.

You can see an example of this in action on e.g. http://calagator.org/events/1250464699, where the same data is available in microformats, microdata, JSON, and XML formats, or on my home page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment