Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Can I prevent JSON encode from converting values

by Your Mother (Bishop)
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"}

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 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://982907]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2018-05-23 02:02 GMT
Find Nodes?
    Voting Booth?