{"id":1777,"date":"2021-01-25T20:48:03","date_gmt":"2021-01-25T20:48:03","guid":{"rendered":"https:\/\/jan.schnasse.org\/blog\/?p=1777"},"modified":"2026-09-28T11:38:03","modified_gmt":"2026-09-28T09:38:03","slug":"rdf-to-json-with-oi-0-5-7","status":"publish","type":"post","link":"https:\/\/jan.schnasse.org\/blog\/2021\/01\/25\/rdf-to-json-with-oi-0-5-7\/","title":{"rendered":"RDF to pretty JSON with oi 0.5.8"},"content":{"rendered":"<pre class=\"lang-java s-code-block hljs\"><code>_:b0 a &lt;http:<span class=\"hljs-comment\">\/\/schema.org\/Book&gt; ;<\/span>\n    &lt;http:<span class=\"hljs-comment\">\/\/schema.org\/name&gt; \"Semantic Web Primer (First Edition)\" ;<\/span>\n    &lt;http:<span class=\"hljs-comment\">\/\/schema.org\/offers&gt; _:b1 ;<\/span>\n    &lt;http:<span class=\"hljs-comment\">\/\/schema.org\/publisher&gt; \"Linked Data Tools\" .<\/span>\n\n_:b1 a &lt;http:<span class=\"hljs-comment\">\/\/schema.org\/Offer&gt; ;<\/span>\n    &lt;http:<span class=\"hljs-comment\">\/\/schema.org\/price&gt; \"2.95\" ;<\/span>\n    &lt;http:<span class=\"hljs-comment\">\/\/schema.org\/priceCurrency&gt; \"USD\" .<\/span><\/code><\/pre>\n<p>Based on this <a href=\"https:\/\/stackoverflow.com\/a\/43638343\/1485527 \">stack overflow answer<\/a> I created <a href=\"https:\/\/github.com\/jschnasse\/oi\">a tool named **oi**<\/a> 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.<\/p>\n<pre class=\"lang-java s-code-block hljs\"><code>\noi -i turtle -t json books.ttl |jq '.[\"@graph\"][0]'\n<\/code><\/pre>\n<p>prints<\/p>\n<pre class=\"lang-java s-code-block hljs\"><code>\n{\n  \"@id\" : \"_:b0\",\n  \"@type\" : \"http:\/\/schema.org\/Book\",\n  \"name\" : \"Semantic Web Primer (First Edition)\",\n  \"offers\" : {\n    \"@id\" : \"_:b1\",\n    \"@type\" : \"http:\/\/schema.org\/Offer\",\n    \"price\" : \"2.95\",\n    \"priceCurrency\" : \"USD\"\n  },\n  \"publisher\" : \"Linked Data Tools\"\n}\n<\/code><\/pre>\n<p>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.<\/p>\n<p>The tool is available as .deb package via it&#8217;s github page at: <a href=\"https:\/\/github.com\/jschnasse\/oi\">https:\/\/github.com\/jschnasse\/oi<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>_:b0 a &lt;http:\/\/schema.org\/Book&gt; ; &lt;http:\/\/schema.org\/name&gt; &#8222;Semantic Web Primer (First Edition)&#8220; ; &lt;http:\/\/schema.org\/offers&gt; _:b1 ; &lt;http:\/\/schema.org\/publisher&gt; &#8222;Linked Data Tools&#8220; . _:b1 a &lt;http:\/\/schema.org\/Offer&gt; ; &lt;http:\/\/schema.org\/price&gt; &#8222;2.95&#8220; ; &lt;http:\/\/schema.org\/priceCurrency&gt; &#8222;USD&#8220; . 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,9],"tags":[],"class_list":["post-1777","post","type-post","status-publish","format-standard","hentry","category-development","category-java"],"_links":{"self":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/1777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/comments?post=1777"}],"version-history":[{"count":1,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/1777\/revisions"}],"predecessor-version":[{"id":4013,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/1777\/revisions\/4013"}],"wp:attachment":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/media?parent=1777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/categories?post=1777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/tags?post=1777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}