Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

parsing json message

by bigup401 (Pilgrim)
on Feb 02, 2022 at 16:37 UTC ( [id://11141075]=perlquestion: print w/replies, xml ) Need Help??

bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

am trying to parse the error message but its not working i dont know why.

am making http post

my $Msg; my $resp = $ua->request($req); if ($resp->is_success) { my $Rep = JSON::XS->new->decode ($resp->decoded_content); $Msg = $Rep->{data}->{error_message}; } else { print "", $resp->decoded_content, "n"; } print "Error: $Msg\n";

and the response is

{ "status": "fail", "data": { "error_message": "Cannot withdraw funds +without Network Fee of 0.00000000 BTC. Maximum withdrawable balance i +s 0.00000000 BTC.", "available_balance": "0.00000000", "max_withdrawa +l_available": "0.00000000", "minimum_balance_needed": "0.00053590", " +coin_fee": "0.00000000", "estimated_network_fee": "0.00000000", "esti +mated_min_custom_network_fee": "0.00000000", "estimated_max_custom_ne +twork_fee": "0.00000000" } }nError:

so am trying to parse error message like this

$Msg = $Rep->{data}->{error_message};

but not working

Replies are listed 'Best First'.
Re: parsing json message
by hippo (Bishop) on Feb 02, 2022 at 16:45 UTC

    $resp->is_success evaluates to false.


    🦛

      thanks, i never even think about this. it has worked

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found