JSON valid numerical param in Perl

0 votes
my $client = new JSON::RPC::Client;

$client->ua->credentials(
 'localhost:8332', 'jsonrpc', 'user' => 'password'  
  );

my $uri = 'http://localhost:8332/';
my $obj = {
  method  => 'sendfrom',
  params  => [$account,$sendto,$btc,6], };

my $res = $client->call( $uri, $obj );

if ($res){
  if ($res->is_error) { print "Error : ", $res->error_message; }
  else { print Dumper($res->result); }
} else {
  print $client->status_line;
 }

Considering the code above $btc is accepted as a param if it is declared:

$btc = 0.01;

Not accepted if it is:

$btc = 0.01;
$btc = sprintf('%.8f', $btc);

Also not accepted if it is:

&ReadParse(*data);
$btc =  $data{'amount'};

I get "500 internal server" error

Sep 11, 2018 in Blockchain by slayer
• 29,370 points
642 views

1 answer to this question.

0 votes

Use 0.0 + sprintf('%.8f', $btc)0.0 + $data{'amount'}

answered Sep 11, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer
+2 votes
5 answers

How do I parse this JSON array in PHP?

/** * Firstly collect the ...READ MORE

answered Sep 3, 2018 in Blockchain by slayer
• 29,370 points
6,363 views
0 votes
1 answer

Cant get a specific value in JSON/PHP

Convert the json-string to a php-array and ...READ MORE

answered Sep 11, 2018 in Blockchain by slayer
• 29,370 points
2,884 views
0 votes
0 answers

Error: Unexpected token o in JSON at position 1

I have been working with Interacting a ...READ MORE

Mar 6, 2019 in Blockchain by saeedi
• 120 points

edited Mar 6, 2019 by Omkar 2,509 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,460 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,945 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,469 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
45,297 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP