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

Interoperability fail with JSON::XS #13

Closed
samuelckaufman opened this issue Jan 29, 2014 · 4 comments
Closed

Interoperability fail with JSON::XS #13

samuelckaufman opened this issue Jan 29, 2014 · 4 comments

Comments

@samuelckaufman
Copy link

Copied from https://rt.cpan.org/Public/Bug/Display.html?id=92548

use Cpanel::JSON::XS ();

my $boolstring = '{ "is_true" : true }';
my $xs_string;
{
    use JSON::XS ();
    my $json = JSON::XS->new;
    $xs_string = $json->decode( $boolstring );
}

my $json = Cpanel::JSON::XS->new;
$json->encode( $xs_string );
#^ dies: encountered object '1', but neither allow_blessed nor
# convert_blessed settings are enabled

This becomes a problem when trying to use Cpanel::JSON::XS for a drop in
replacement without replacing JSON::XS everywhere.

@rurban
Copy link
Owner

rurban commented Jan 30, 2014

Thanks for the testcase. The boolean wrapper needs to accept both objects.

sub is_bool($) {
   UNIVERSAL::isa $_[0], "Cpanel::JSON::XS::Boolean"
     or UNIVERSAL::isa $_[0], "JSON::XS::Boolean"
}

But in this case JSON::XS::Boolean fails to accept Cpanel::JSON::XS::Boolean,
which is I am afraid unfixable currently, as Marc Lehmann will not do it.
So it looks like we will have to rename our boolean object back to JSON::XS::Boolean and risc a little CPAN conflict.

I'll check it out.

rurban pushed a commit that referenced this issue Jan 30, 2014
the internal boolean objects are now blessed into JSON::XS::Boolean
Fixes issue #13 and [cpan #92548] (samuel.c.kaufman)

t/96_interop.t: added
LICENSE section to pod added for t/z_kwalitee.t
README: fixed some pod spelling errors in (David Steinbrunner)
@rurban
Copy link
Owner

rurban commented Jan 30, 2014

Fixed in 2.3404:
- fix interop with JSON::XS booleans,
the internal boolean objects are now blessed into JSON::XS::Boolean
#13 and cpan #92548
- t/96_interop.t: added

@rurban rurban closed this as completed Jan 30, 2014
@samuelckaufman
Copy link
Author

great, thanks again

@rurban
Copy link
Owner

rurban commented Apr 15, 2014

Note that JSON-2.90 and esp. JSON-XS-3.01 broke that again, so I had to fix that with Cpanel-JSON-XS-3.0101

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