Module: RDF::JSON

Defined in:
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-json-cf38585bd18b/lib/rdf/json.rb,
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-json-cf38585bd18b/lib/rdf/json/extensions.rb,
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-json-cf38585bd18b/lib/rdf/json/format.rb,
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-json-cf38585bd18b/lib/rdf/json/reader.rb,
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-json-cf38585bd18b/lib/rdf/json/version.rb,
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-json-cf38585bd18b/lib/rdf/json/writer.rb

Overview

RDF::JSON is an RDF/JSON extension for RDF.rb.

Examples:

Requiring the RDF::JSON module

require 'rdf/json'

Parsing RDF statements from an RDF/JSON file

RDF::JSON::Reader.open("etc/doap.json") do |reader|
  reader.each_statement do |statement|
    puts statement.inspect
  end
end

Serializing RDF statements into an RDF/JSON file

RDF::JSON::Writer.open("etc/test.json") do |writer|
  graph.each_statement do |statement|
    writer << statement
  end
end

Serializing RDF values into RDF/JSON strings

RDF::Node.new('foobar').to_rdf_json.to_json
RDF::URI.new("http://rdf.rubyforge.org/").to_rdf_json.to_json
RDF::Literal.new("Hello, world!").to_rdf_json
RDF::Literal.new("Hello, world!", :language => 'en-US').to_rdf_json.to_json
RDF::Literal.new(3.1415).to_rdf_json.to_json
RDF::Literal.new('true', :datatype => RDF::XSD.boolean).to_rdf_json.to_json
RDF::Statement.new(s, p, o).to_rdf_json.to_json

See Also:

Author:

Defined Under Namespace

Modules: Extensions, VERSION Classes: Format, Reader, Writer