Module: JSON::LD

Defined in:
lib/json/ld.rb,
lib/json/ld/api.rb,
lib/json/ld/frame.rb,
lib/json/ld/utils.rb,
lib/json/ld/conneg.rb,
lib/json/ld/expand.rb,
lib/json/ld/format.rb,
lib/json/ld/reader.rb,
lib/json/ld/to_rdf.rb,
lib/json/ld/writer.rb,
lib/json/ld/compact.rb,
lib/json/ld/context.rb,
lib/json/ld/flatten.rb,
lib/json/ld/from_rdf.rb,
lib/json/ld/resource.rb,
lib/json/ld/html/rexml.rb,
lib/json/ld/html/nokogiri.rb,
lib/json/ld/streaming_writer.rb

Overview

**‘JSON::LD`** is a JSON-LD extension for RDF.rb.

Examples:

Requiring the ‘JSON::LD` module

require 'json/ld'

Parsing RDF statements from a JSON-LD file

JSON::LD::Reader.open("etc/foaf.jld") do |reader|
  reader.each_statement do |statement|
    puts statement.inspect
  end
end

See Also:

Author:

Defined Under Namespace

Modules: Compact, Expand, Flatten, Frame, FromRDF, StreamingWriter, ToRDF, Utils, VERSION Classes: API, BlankNodeMapper, BlankNodeNamer, BlankNodeUniqer, ContentNegotiation, Context, Format, JsonLdError, Reader, Resource, Writer

Constant Summary collapse

JSON_LD_NS =

JSON-LD profiles

"http://www.w3.org/ns/json-ld#"
PROFILES =
%w(expanded compacted flattened framed).map {|p| JSON_LD_NS + p}.freeze
DEFAULT_CONTEXT =

Default context when compacting without one being specified

"http://schema.org"
KEYWORDS =
Set.new(%w(
  @base
  @container
  @context
  @default
  @direction
  @embed
  @explicit
  @first
  @graph
  @id
  @import
  @included
  @index
  @json
  @language
  @list
  @nest
  @none
  @omitDefault
  @propagate
  @protected
  @preserve
  @requireAll
  @reverse
  @set
  @type
  @value
  @version
  @vocab
)).freeze
NC_REGEXP =

Regexp matching an NCName.

Regexp.new(
%{^
  (?!\\\\u0301)             # ́ is a non-spacing acute accent.
                            # It is legal within an XML Name, but not as the first character.
  (  [a-zA-Z_]
   | \\\\u[0-9a-fA-F]
  )
  (  [0-9a-zA-Z_\.-]
   | \\\\u([0-9a-fA-F]{4})
  )*
$},
Regexp::EXTENDED)
NATIVE_DATATYPES =

Datatypes that are expressed in a native form and don’t expand or compact

[RDF::XSD.integer.to_s, RDF::XSD.boolean.to_s, RDF::XSD.double.to_s]
JSON_STATE =
JSON::State.new(
  indent:       "  ",
  space:        " ",
  space_before: "",
  object_nl:    "\n",
  array_nl:     "\n"
)
MAX_CONTEXTS_LOADED =
50