davorg-cpan / moox-role-json_ld Goto Github PK
View Code? Open in Web Editor NEWMoo role to easily add JSON-LD generation into a class
Moo role to easily add JSON-LD generation into a class
It (usually) eliminates hiccups in the building releases.
The final backslash is missing from the context.
If MooX::Alias is used to create an alias for a MooX::JSON_LD attribute, then it seems to "overwrite" any changes to the attribute.
Many (most) of the properties of schema.org schemata are multivalued, including nested ones, for example Organization.employees, Person.children, MusicComposition.composer (https://schema.org/Person#music-2), but such properties seem to not be supported by this role:
use Data::Dumper;
{
package LD::Employee;
use Moo;
use Types::Standard qw/Str ArrayRef InstanceOf/;
use MooX::JSON_LD 'Person';
has name => (
is => 'ro',
json_ld => 'name',
);
no Moo;
no MooX::JSON_LD;
}
{
package LD::Org;
use Moo;
use MooX::JSON_LD 'Organization';
use Types::Standard qw/ArrayRef InstanceOf/;
has 'org_name' => (
is => 'ro',
json_ld => 'name',
);
has employees => (
is => 'rw',
isa => ArrayRef->of(InstanceOf->of("LD::Employee")),
json_ld => 'employee',
);
}
my $e1 = LD::Employee->new( name => 'Joe Soap' );
my $e2 = LD::Employee->new( name => 'John Brown' );
my $employees = [$e1, $e2];
print Dumper( map $_->json_ld, @$employees );
my $o = new LD::Org( org_name => 'Foo Inc' );
$o->employees([ $e1, $e2 ]);
print Dumper( $o->json_ld );
Returns the error
encountered object 'LD::Employee=HASH(0x27ab040)', but neither allow_blessed, convert_blessed nor allow_tags settings are enabled (or TO_JSON/FREEZE method missing) at /home/perl/perl5/lib/perl5/MooX/Role/JSON_LD.pm line 233
Shouldn't Moose be a test prereq?
MetaCPAN is using RT for the issue queue. If you prefer to use GitHub, then you should probably add the following to METAMERGE "resources" key in Makefile.
:
"bugtracker" : {
"web" : "https://github.com/davorg/moox-role-json_ld/issues"
},
If you want to stick with RT, then you should probably make that explicit instead:
"bugtracker" : {
"mailto": "bug-MooX-Role-JSON_LD@rt.cpan.org",
"web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=MooX-Role-JSON_LD"
},
and of course, disable the issues queue on this git repo.
Running the following code:
use Test::More;
use Data::Dumper;
{
package LD::Person;
use Moo;
use Types::Standard qw/Str ArrayRef InstanceOf/;
use MooX::JSON_LD 'Person';
has name => (
is => 'ro',
json_ld => 'name',
);
has children => (
is => 'ro',
json_ld => 'children',
);
no Moo;
no MooX::JSON_LD;
}
my $c = LD::Person->new( name => 'Carla Foo');
my $p = LD::Person->new( name => 'Sam Foo', children => $c);
diag $p->json_ld;
done_testing;
Causes the script to hang on the json_ld call. This only affects JSONLD objects that contain instances of the same type (in this case LD::Person).
$ = MooX::Role::JSON_LD::json_ld_data(ref(LD::Person)) called from file `lib/perl5/site_perl/5.10.1/MooX/Role/JSON_LD.pm' line 189
$ = MooX::Role::JSON_LD::_resolve_nested(ref(LD::Person)) called from file `lib/perl5/site_perl/5.10.1/MooX/Role/JSON_LD.pm' line 213
@ = MooX::Role::JSON_LD::json_ld_data(ref(LD::Person)) called from file `lib/perl5/site_perl/5.10.1/MooX/Role/JSON_LD.pm' line 240
@ = MooX::Role::JSON_LD::json_ld(ref(LD::Person)) called from file `./ld3.pl' line 24
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.