Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Parsing JSON out of an incremental stream

by Sec (Monk)
on Feb 18, 2019 at 17:40 UTC ( #1230122=note: print w/replies, xml ) Need Help??


in reply to Re: Parsing JSON out of an incremental stream
in thread Parsing JSON out of an incremental stream

For anyone following along.
$ua->add_handler( response_data => sub { my($response, $ua, $h, $data) = @_; eval { my $result = $json->incr_parse( $data ); if (defined $result){ print Dumper $result; }; }; if ($@){ print STDERR "Error: $@\n"; die }; 1; } );
is a pretty nice solution in my eyes.

The eval/catch is a bit of an eyesore, but LWP seems to silently eat all errors in handlers, and just not call them anymore which makes debugging quite difficult.

Also make sure you install JSON::XS - the "core" version of JSON::PP may decide to die on you.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2019-10-17 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?