_:b0 a <http://schema.org/Book> ;
<http://schema.org/name> "Semantic Web Primer (First Edition)" ;
<http://schema.org/offers> _:b1 ;
<http://schema.org/publisher> "Linked Data Tools" .
_:b1 a <http://schema.org/Offer> ;
<http://schema.org/price> "2.95" ;
<http://schema.org/priceCurrency> "USD" .
Based on this stack overflow answer I created a tool named **oi** that provides some capabilities to convert rdf to json via command line. If no frame is provided via cli, the tool aims to generate @context entries for most situations.
oi -i turtle -t json books.ttl |jq '.["@graph"][0]'
prints
{
"@id" : "_:b0",
"@type" : "http://schema.org/Book",
"name" : "Semantic Web Primer (First Edition)",
"offers" : {
"@id" : "_:b1",
"@type" : "http://schema.org/Offer",
"price" : "2.95",
"priceCurrency" : "USD"
},
"publisher" : "Linked Data Tools"
}
The tool attempts to create various output formats. The result is not meant to be 100% correct for each and every case. The overall idea is to provide adhoc conversions just as one step in a conversion pipeline.
The tool is available as .deb package via it’s github page at: https://github.com/jschnasse/oi.