Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 75867
Status: resolved
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: 'spro^^*%*^6ut# [...] &$%*c
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.53
Fixed in: (no value)



Subject: is_xs and is_pp don’t work
I tested this with version 2.53. Both these methods seem to be calling other methods that do not exist: bash-3.2$ perl -Ilib -MJSON -e 'print new JSON->is_pp' Can't locate object method "xs" via package "JSON" at lib/JSON.pm line 198. bash-3.2$ perl -Ilib -MJSON -e 'print new JSON->is_xs' Can't locate object method "module" via package "JSON" at lib/JSON.pm line 193.
Try it; JSON->backend->is_pp; JSON->backend->is_xs;
On Sun Mar 18 21:23:53 2012, MAKAMAKA wrote: Show quoted text
> Try it; > > JSON->backend->is_pp; > JSON->backend->is_xs; >
In that case I think you have a doc bug: ----- So, your program should not depend on the backend module, especially returned objects should not be modified. my $json = JSON->new; # XS or PP? $json->{stash} = 'this is xs object'; # this code may raise an error! To check the backend module, there are some methods - C<backend>, C<is_pp> and C<is_xs>. JSON->backend; # 'JSON::XS' or 'JSON::PP' JSON->backend->is_pp: # 0 or 1 JSON->backend->is_xs: # 1 or 0 $json->is_xs; # 1 or 0 $json->is_pp; # 0 or 1 ----- In the above snippet from JSON.pm’s pod, $json is assigned the result of JSON->new. Then further down you have $json->is_xs and $json->is_pp. But those don‘t work on $json itself.
I had checked old versions and found that your point is right. Object methods is_xs/pp were broken. I fixed it in my repository. https://github.com/makamaka/JSON/ Thank you and sorry for my lazy response. On 2012-3月-19 月 00:36:40, SPROUT wrote: Show quoted text
> On Sun Mar 18 21:23:53 2012, MAKAMAKA wrote:
> > Try it; > > > > JSON->backend->is_pp; > > JSON->backend->is_xs; > >
> > In that case I think you have a doc bug: > > ----- > So, your program should not depend on the backend module, especially > returned objects should not be modified. > > my $json = JSON->new; # XS or PP? > $json->{stash} = 'this is xs object'; # this code may raise an error! > > To check the backend module, there are some methods - C<backend>, > C<is_pp> and > C<is_xs>. > > JSON->backend; # 'JSON::XS' or 'JSON::PP' > > JSON->backend->is_pp: # 0 or 1 > > JSON->backend->is_xs: # 1 or 0 > > $json->is_xs; # 1 or 0 > > $json->is_pp; # 0 or 1 > ----- > > In the above snippet from JSON.pm’s pod, $json is assigned the result > of JSON->new. Then > further down you have $json->is_xs and $json->is_pp. But those don‘t > work on $json itself.