Skip Menu |
 

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 31647
Status: open
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: andy [...] hexten.net
Cc:
AdminCc:

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



Subject: Support objToJson( $scalar )
Download (untitled) / with headers
text/plain 306b
It seems arbitrary that one can't pass a scalar to objToJson(). This perl -MJSON -le 'print objToJson(1)' prints nothing - i.e. it silently fails to do the expected thing. There seems to be no architectural reason that objToJson / jsonToObj can't handle scalars. Coud the default behaviour be modified?
Download (untitled) / with headers
text/plain 471b
Show quoted text
>There seems to be no architectural reason that objToJson / jsonToObj
can't handle scalars. Show quoted text
>Coud the default behaviour be modified?
No, I won't. JSON format doesn't allow any simple scalars. So, objToJson and jsonToObj too. However, since JSON module 2.0, You can write the below code. JSON->new->allow_nonref->encode(1); JSON->new->allow_nonref->decode(1); (Additionally, objToJson and jsonToObj are obsoleted.) Please look up and try new JSON module. Thanks,
Subject: Re: [rt.cpan.org #31647] Support objToJson( $scalar )
Date: Wed, 19 Dec 2007 12:13:24 +0000
To: bug-JSON [...] rt.cpan.org
From: Andy Armstrong <andy [...] hexten.net>
Download (untitled) / with headers
text/plain 672b
Thanks :) On 19 Dec 2007, at 05:53, Makamaka Hannyaharamitu via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=31647 > >
>> There seems to be no architectural reason that objToJson / jsonToObj
> can't handle scalars.
>> Coud the default behaviour be modified?
> > No, I won't. > JSON format doesn't allow any simple scalars. > So, objToJson and jsonToObj too. > > However, since JSON module 2.0, > You can write the below code. > > JSON->new->allow_nonref->encode(1); > JSON->new->allow_nonref->decode(1); > > (Additionally, objToJson and jsonToObj are obsoleted.) > > Please look up and try new JSON module. > > Thanks, >
-- Andy Armstrong, Hexten
Download (untitled) / with headers
text/plain 1.1k
On Wed Dec 19 00:53:54 2007, MAKAMAKA wrote: Show quoted text
> >There seems to be no architectural reason that objToJson / jsonToObj
> can't handle scalars.
> >Coud the default behaviour be modified?
> > No, I won't. > JSON format doesn't allow any simple scalars. > So, objToJson and jsonToObj too.
So not only did you quickly switch over to a brand-new interface, you're publicly announcing that you refuse to follow the standard, polite practice of having a deprecation period where the old API is supported (with warnings) while the new API is encouraged. Failing that, you could have done a better job of announcing the change up front (was this even announced anywhere? I never heard of it) and giving people plenty of lead time to know when the need to change their code. Instead, the first I heard about this was when I received a confusing bug report on my Test::JSON module. Since you can no longer give us lead time to prepare for the change, would you please reconsider and at least provide a backwards-compatible API (warnings are fine) that give people a transition period rather than just breaking their code? Cheers, Ovid
Download (untitled) / with headers
text/plain 539b
On Wed Dec 19 00:53:54 2007, MAKAMAKA wrote: Show quoted text
> >There seems to be no architectural reason that objToJson / jsonToObj
> can't handle scalars.
> >Coud the default behaviour be modified?
> > No, I won't. > JSON format doesn't allow any simple scalars. > So, objToJson and jsonToObj too.
Another thing: take a look at the current Makefile.PL (http://search.cpan.org/src/INGY/YAML-0.66/Makefile.PL) for YAML. It at least warns the user about the backwards-incompatibility and lets gives them a chance to investigate further. Cheers, Ovid
Download (untitled) / with headers
text/plain 518b
First thing, sorry to trouble you. I thought the announcment is plenty since I announced 7 months ago in http://search.cpan.org/src/MAKAMAKA/JSON-1.14/Changes . Additionally, I did not yet remove objToJson and jsonToObj. Instead of the deletion, they will warn. But I silly forgot to retain them as the object methods. It was fixed in 2.01 yesterday. Anyhow, I cannot escape the charge of negligence. Show quoted text
> Another thing: take a look at the current Makefile.PL
My Makefile.PL warns too since version 1.99. Regards,
Download (untitled) / with headers
text/plain 599b
Just an FYI: I've uploaded a new Test::JSON which should be on the CPAN soon. I've made it work with both the old and new JSON interfaces. After I'm comfortable with the changes, I may remove support for the old (this allows people to upgrade Test::JSON even if they don't have a C compiler to use the new JSON.pm). As for your announcement 7 months ago about the change, I hadn't seen it. I'm not sure if there is really any good way of propagating those announcements. This really does seem like a tough problem. Sorry for giving you grief about it and I appreciate your help! Cheers, Ovid


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.