Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Can I prevent JSON encode from converting values

by Your Mother (Chancellor)
on Jul 20, 2012 at 21:06 UTC ( #982907=note: print w/ replies, xml ) Need Help??


in reply to Can I prevent JSON encode from converting values

Upgrade? And ensure you've got JSON::XS. I've got 2.22.

perl -MJSON -le '$var = "5.0"; print JSON->new->allow_nonref->encode({ +$var => $var})' {"5.0":"5.0"}


Comment on Re: Can I prevent JSON encode from converting values
Download Code
Replies are listed 'Best First'.
Re^2: Can I prevent JSON encode from converting values
by somekindafreak (Acolyte) on Jul 20, 2012 at 22:14 UTC
    I have JSON::XS version 2.29. Perhaps I should downgrade? Actually I am developing for a static perl environment that I can't touch either way.

      I'm on 2.32 and get { "5.0": "5.0" }.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
        I did get this working in another perl env that has an updated version of JSON. Glad it is just a necessary rev. My JSON.pm is actually 2.21 with JSON::XS saying 2.29. In another location with 2.27 it does work perfectly. I will press for an update and manage until then. thanks everyone

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://982907]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2015-07-31 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls