RDFa 1.1 meets JSON-LD in the Distiller…

Part of Data

Author(s) and publish date

By:
Published:

I have blogged recently on the update of the RDFa 1.1 Distiller. I have just added a cool new feature. Up to today, the possible serializations were RDF/XML, Turtle, and N Triples. Although not yet final, I decided to add a JSON-LD serialization, too, in spite of the fact that JSON-LD is not yet final either (it is under development by a W3C Community Group). However, adding this to the system it shows the potentials of this combination…

An example may be the schema.org example I used in another blog lately:

<div vocab="http://schema.org/" typeof="Product">
  <img property="image" src="dell-30in-lcd.jpg" />
  <span property="name">Dell UltraSharp 30" LCD Monitor</span>

  <div property="aggregateRating" typeof="AggregateRating">
    <span property="ratingValue">87</span>
    out of <span property="bestRating">100</span>
    based on <span property="ratingCount">24</span> user ratings
  </div>

  <div property="offers" typeof="AggregateOffer">
	<span property="lowPrice">$1250</span>
	to <span property="highPrice">$1495</span>
	from <span property="offerCount">8</span> sellers
  </div>

  Sellers:
  <div property="offers" typeof="Offer" >
    <a property="url" href="save-a-lot-monitors.com/dell-30.html">
     Save A Lot Monitors - $1250</a>
  </div>
  
  <div property="offers" typeof="Offer">
    <a property="url" href="jondoe-gadgets.com/dell-30.html">
    Jon Doe's Gadgets - $1350</a>
  </div>
  ...
</div>     

Running this through the distiller, one gets the following JSON output:

{
    "@context": {
        "@vocab": "http://schema.org/",
        "@coerce": {
            "@iri": [
                "http://schema.org/image",
                "http://schema.org/offers",
                "http://schema.org/url",
                "http://schema.org/aggregateRating"
            ]
        }
    },
    "@type": "Product",
    "aggregateRating": {
        "@type": "AggregateRating",
        "ratingCount": "24",
        "ratingValue": "87",
        "bestRating": "100"
    },
    "offers": [
        {
            "@type": "Offer",
            "url": "http://www.example.org/save-a-lot-monitors.com/dell-30.html"
        },
        {
            "@type": "AggregateOffer",
            "lowPrice": "$1250",
            "highPrice": "$1495",
            "offerCount": "8"
        }
    ],
    "name": "Dell UltraSharp 30" LCD Monitor",
    "image": "http://www.example.org/dell-30in-lcd.jpg"
}

Of course, the generated JSON may be a bit more complex, e.g., if the original page contains other RDFa attributes generating other triples. But it still looks pretty readable to me…

Related RSS feed

Comments (0)

Comments for this post are closed.