Code Monkey home page Code Monkey logo

moox-role-json_ld's People

Contributors

anirvan avatar choroba avatar davorg avatar dependabot[bot] avatar jj avatar manwar avatar robrwo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

moox-role-json_ld's Issues

Should module metadata use Github or RT for issues?

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.

Unable to handle multivalued properties that are also do JSON_LD

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

Nesting JSON_LD objects of the same type causes ->json_ld to hang in json_ld_data

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.