logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

JSONLD - A toolkit for transforming JSON-LD data.

Author

       Gregory Todd Williams  "<gwilliams@cpan.org>"

Bugs

       Please   report   any   bugs   or   feature   requests   to   through   the   GitHub   web  interface  at
       <https://github.com/kasei/perl-jsonld/issues>.

Description

       This module implements part of the JSON-LD 1.1 standard for manipulating JSON data as linked data.

       This version provides full support for the JSON-LD 1.1 "Expansion" and "toRdf" transformations (the
       latter primarily being useful through a subclass of JSON-LD, such as that provided by
       AtteanX::Parser::JSONLD).  Partial support for the "Compaction" transformation is provided, but it
       contains many known deficiencies. Full support for "Compaction" may be forthcoming in a future release.
       No other JSON-LD transformation are supported at this time.

Methods

       "compact( $data, [$context] )"
           Returns the JSON-LD compaction of $data, using the optionally supplied $context.

           NOTE: Support for JSON-LD Compaction is not fully supported in this version.

       "expand( $data, [expandContext => $ctx] )"
           Returns the JSON-LD expansion of $data.

           If  an  "expandContext" value is supplied, it is used to construct the initial active context for the
           expansion process.

       "to_rdf( $data, [expandContext => $ctx] )"
           Returns the dataset generated by turning the JSON-LD expansion of $data into RDF.

           If an "expandContext" value is supplied, it is passed to the "expand" function call that takes  place
           internally prior to generating RDF.

           Note: this method must be called on a "JSONLD" subclass which implements the RDF-related methods:

           •   default_graph()

           •   new_dataset()

           •   "new_triple($s, $p, $o)"

           •   "new_quad($s, $p, $o, $g)"

           •   new_iri($value)

           •   new_graphname($value)

           •   new_blank( [$id] )

           •   "new_lang_literal($value, $lang)"

           •   "new_dt_literal($value, $datatype)"

           •   "add_quad($quad, $dataset)"

           See AtteanX::Parser::JSONLD for an API that provides this functionality.

Name

       JSONLD - A toolkit for transforming JSON-LD data.

See Also

       <irc://irc.perl.org/#perlrdf>
       AtteanX::Parser::JSONLD
       <https://www.w3.org/TR/json-ld11/>
       <https://www.w3.org/TR/json-ld-api/>
       MooX::Role::JSON_LD

Synopsis

         use v5.14;
         use JSON;
         use JSONLD;

         my $infile = 'test.jsonld';
         open(my $fh, '<', $infile) or die $!;
         my $content   = do { local($/); <$fh> };
         my $data = JSON->new()->boolean_values(0, 1)->decode($content);

         my $jld = JSONLD->new();
         my $expanded  = $jld->expand($data);

Version

       This document describes JSONLD version 0.006.

See Also