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

Re^5: Int becomes String when I convert to json

by choroba (Cardinal)
on May 10, 2022 at 20:18 UTC ( [id://11143757]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Int becomes String when I convert to json
in thread Int becomes String when I convert to json

You also need to
use Cpanel::JSON::XS;
Its encode_json takes the extra parameter, the ::Type module just exports the types' names.

BTW,

(my $hashref) = @_;
is usually written
my ($hashref) = @_;
so you can easily add more parameters if needed without having to move the parenthesis around.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Server Error (Error ID 3353706c2135416)

An error has occurred. The site administrators have been notified of the problem and will likely soon fix it. We thank you, for you're patients.

Replies are listed 'Best First'.
Re^6: Int becomes String when I convert to json
by bartender1382 (Beadle) on May 10, 2022 at 23:52 UTC

    Yes,

    use Cpanel::JSON::XS;

    was already in there. Just bad cut & pasting. As for:

    (my $hashref) = @_;

    was a typo that seems to work, although I will fix that now. Just to ask tho, is there a reason I shouldn't syntax for single variables?

      I don't understand the question. Are you asking why you shouldn't include my in the parentheses? I've already explained that in my previous post.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-03-29 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found