Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2019-03-18 21:26 GMT
Find Nodes?
    Voting Booth?
    How do you Carpe diem?

    Results (89 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!