Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with JSON::JOM #33

Closed
nuba opened this issue Aug 13, 2012 · 4 comments
Closed

Error with JSON::JOM #33

nuba opened this issue Aug 13, 2012 · 4 comments

Comments

@nuba
Copy link

nuba commented Aug 13, 2012

Just ran into this yesterday:

$ use JSON::JOM qw/from_json/; 
$ use Data::Printer;           
$ use Data::Dumper;            

my test case

$ my $min_json = '{"alpha":1}';
{"alpha":1}

and the output with Data::Dumper

$ Dumper from_json $min_json
$VAR1 = bless( {
                 'alpha' => bless( do{\(my $o = 1)}, 'JSON::JOM::Value' )
               }, 'JSON::JOM::Object' );

and where Data::Printer breaks

$ p from_json $min_json
Use of uninitialized value $ref in exists at /home/nuba/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/Data/Printer.pm line 257.
Use of uninitialized value $ref in exists at /home/nuba/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/Data/Printer.pm line 269.
Runtime error: Package::Stash->new must be passed the name of the package to access at /home/nuba/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/Data/Printer.pm line 703.

versions I have here:

Data::Dumper 2.135_06
JSON::JOM 0.501
Data::Printer 0.32
@garu
Copy link
Owner

garu commented Aug 13, 2012

Can you help me reproduce? Here it seems to work fine:

$ perl -MDDP -MJSON::JOM=from_json -E 'p from_json q[{"alpha":1}]'
JSON::JOM::Object {
Parents JSON::JOM::Node
public methods (5) : can, new, TO_JSON, toJSON, typeof
private methods (0)
internals: {
alpha JSON::JOM::Value
} (tied to JSON::JOM::Object::Tie)
} (tied to JSON::JOM::Object::Tie) (tied to JSON::JOM::Object::Tie)

@garu
Copy link
Owner

garu commented Aug 13, 2012

nevermind. Got it!

@nuba
Copy link
Author

nuba commented Aug 16, 2012

Explored the problem a little more, and It seems the root is in how JSON::JOM::Value uses UNIVERSAL::ref

replacing

sub ref { return }

with

sub ref { return 'JSON::JOM::Value' }

then when loading JSON::JOM first,
Data::Printer outputs (filtered with Data::Printer::Filter::JSON):

\ {
    a   \ false,
    b   \ "lalala",
    c   {
        ca   [
            [0] \ 1,
            [1] \ 2,
            [2] \ 3
        ] (tied to JSON::JOM::Array::Tie)
    } (tied to JSON::JOM::Object::Tie)
} (tied to JSON::JOM::Object::Tie) (tied to JSON::JOM::Object::Tie)

and when loading Data::Printer first, the output is

\ \ {
    a   \ false,
    b   \ "lalala",
    c   \ \ {
        ca   \ \ [
            [0] \ 1,
            [1] \ 2,
            [2] \ 3
        ]
    }
}

hope it helps :)

@garu
Copy link
Owner

garu commented Jun 28, 2018

Hey Nuba! Wow, this is super old. JSON::JOM is not even on CPAN anymore, and I can't get the version from backpan to install properly, so I don't know whether the new version of Data::Printer still has this issue or not.

I'm going to close this and if we bump into it again, we'll reopen :)

Saudade de vc cara! Um grande abraço \o/

@garu garu closed this as completed Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants