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,050 points
19 views

1 answer to this question.

0 votes

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

answered Sep 11, 2018 by digger
• 27,620 points

Related Questions In Blockchain

+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,050 points
798 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,050 points
87 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 in Blockchain by saeedi
• 120 points

edited Mar 6 by Omkar 235 views
0 votes
1 answer

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

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,320 points
56 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
105 views
0 votes
1 answer
+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
• 27,620 points
2,119 views
0 votes
1 answer