[whatwg] Was is considered to use JSON-LD instead of creating application/microdata+json?
Ian Hickson
ian at hixie.ch
Wed Aug 8 16:17:41 PDT 2012
On Wed, 8 Aug 2012, Markus Lanthaler wrote:
>
> 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.
It wasn't. What would be the purpose of doing so?
The only reason there's a MIME type at all (rather than just using JSON's
directly) was to enable filtering of copy-and-paste and drag-and-drop
payloads; would JSON-LD enable that also?
> 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" } ]
> }
> }
> ]
> }
> ]
> }
That seems like it is strictly more complicated (trivially so, but still).
What is the advantage?
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list