JSONLD(3pm)

πŸ“¦
version 0.006 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 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 $data into 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 πŸ‘‘

go forth and read, iykyk. ⭐


πŸŽ€ AUTHOR πŸŽ€

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


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