Module: RDF::JSON

Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-json-7d579de01769/lib/rdf/json.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-json-7d579de01769/lib/rdf/json/format.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-json-7d579de01769/lib/rdf/json/reader.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-json-7d579de01769/lib/rdf/json/writer.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-json-7d579de01769/lib/rdf/json/version.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-json-7d579de01769/lib/rdf/json/extensions.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.rj") 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.rj") 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("https://rubygems.org/gems/rdf/").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