JSONLD(3pm)
πΈ JSONLD πΈ
ok so bestie, this is JSONLD β a toolkit for transforming JSON-LD data. that's the whole vibe. it lives in the User Contributed Perl Documentation corner of your 3pm world and it is serving linked data realness. π
β¨ VERSION β¨
this doc is describing JSONLD version 0.006. iconic. no notes. π
π¦ SYNOPSIS π¦
here's the little starter pack, copy it exactly, don't freestyle it:
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);
like. read the file, slurp it, decode it, expand it. that's the whole arc. π
π DESCRIPTION π
this module implements part of the JSON-LD 1.1 standard for manipulating JSON data as linked data. it's giving "we did the homework but not all the homework." π
this version gives you full support for the JSON-LD 1.1 "Expansion" and "toRdf" transformations. and ngl, that toRdf one is mainly useful through a subclass of JSON-LD β like the one AtteanX::Parser::JSONLD hooks you up with. π
Partial support for the "Compaction" transformation? yeah, it's there, but it comes with many known deficiencies. it's giving group project energy. full support for "Compaction" may be forthcoming in a future release β so like, watch this space, bestie. β¨
No other JSON-LD transformations are supported at this time. periodt. π
π 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. don't come for me, I'm just the messenger. π
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. so it's setting the whole mood for the expansion, basically. πΈ
to_rdf( $data, [expandContext => $ctx] )β returns the dataset generated by turning the JSON-LD expansion of$datainto RDF.
if an expandContext value is supplied, it gets passed to the expand function call that happens internally before generating RDF. team player behavior. π«Ά
Note: this method must be called on a JSONLD subclass which implements the RDF-related methods listed below. you cannot just call it on plain JSONLD and expect magic, bestie, it will not slay. π
the RDF-related methods your subclass has to bring to the function:
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)
and if you want an API that already provides all of this functionality, go look at AtteanX::Parser::JSONLD. it's the pre-built bestie. π
π BUGS π
found a bug? want a feature? please report any bugs or feature requests through the GitHub web interface at:
<https://github.com/kasei/perl-jsonld/issues>
we love a tidy issue tracker. so organized. so main character. π₯
π 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
go forth and read, iykyk. β
π AUTHOR π
Gregory Todd Williams "<gwilliams@cpan.org>"
π COPYRIGHT π
Copyright (c) 2019--2020 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
ok that's the whole page bestie, you're officially fluent π and one last little sign-off for the receipts: this was perl v5.38.2, dated 2024-01-21, and the page itself is JSONLD(3pm). mwah. π«Άβ¨
π¦ where this page comes from
- debian trixie: libjsonld-perl 0.006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libjsonld-perl 0.006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libjsonld-perl 0.006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libjsonld-perl 0.006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms