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/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/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, Context, Format, JsonLdError, Reader, Resource, Writer

Constant Summary collapse

INITIAL_CONTEXT =

Initial context

{
  RDF.type.to_s => {"@type" => "@id"}
}.freeze
KEYWORDS =
Set.new(%w(
  @base
  @container
  @context
  @default
  @embed
  @explicit
  @id
  @index
  @graph
  @language
  @list
  @nest
  @omitDefault
  @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"
)