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

Markus Lanthaler markus.lanthaler at gmx.net
Wed Aug 8 02:11:31 PDT 2012


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



More information about the whatwg mailing list