W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2012

[whatwg] Was is considered to use JSON-LD instead of creating application/microdata+json?

From: Markus Lanthaler <markus.lanthaler@gmx.net>
Date: Wed, 8 Aug 2012 11:11:31 +0200
To: <whatwg@lists.whatwg.org>
Message-ID: <00d001cd7545$d20c7f40$76257dc0$@lanthaler@gmx.net>
Hi all,

I just sent this e-mail in response to Michael[tm] Smith's request [1] to
register application/microdata+json to ietf-types but I think this is a
better place to discuss this... so sorry for the cross-post.

I was wondering whether it was considered to use JSON-LD [2] instead of
creating application/microdata+json. The resulting output would be more or
less the same.

For example the following application/microdata+json document:

{
  "items": [
    {
      "id": "http://example.com/id1",
      "type": [ "http://example.com/type1" ],
      "properties": {
        "property1": [ "value1" ],
        "property2": [
          {
            "id": "http://example.com/id2",
            "type": [ 
              "http://example.com/type2", 
              "http://example.com/type3"
            ],
            "properties": {
              "property3": [ "http://example.com/value3" ]
            }
          }
        ]
      }
    }
  ]
}

Could be expressed in JSON-LD as

{
  "@graph": [
    {
      "@id": "http://example.com/id1",
      "@type": [ "http://example.com/type1" ],
      "property1": [ "value1" ],
      "property2": [
        {
          "@id": "http://example.com/id2",
          "@type": [ 
            "http://example.com/type2", 
            "http://example.com/type3"
          ],
          "properties": {
            "property3": [ { "@id": "http://example.com/value3" } ]
          }
        }
      ]
    }
  ]
}

Or, by aliasing JSON-LD's keywords even as which is almost exactly the same
as the application/microdata+json counterpart:

{
  "@context": {
    "id": "@id",
    "type": "@type",
    "items": "@graph"
  },
  "items": [
    {
      "id": "http://example.com/id1",
      "type": [ "http://example.com/type1" ],
      "property1": [ "value1" ],
      "property2": [
        {
          "id": "http://example.com/id2",
          "type": [ 
            "http://example.com/type2", 
            "http://example.com/type3"
          ],
          "properties": {
            "property3": [ { "@id": "http://example.com/value3" } ]
          }
        }
      ]
    }
  ]
}


[1] http://www.ietf.org/mail-archive/web/ietf-types/current/msg01714.html
[2] http://www.w3.org/TR/json-ld-syntax/


--
Markus Lanthaler
@markuslanthaler
Received on Wednesday, 8 August 2012 09:12:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:09 GMT