in reply to Re: Parsing JSON out of an incremental stream
in thread Parsing JSON out of an incremental stream
is a pretty nice solution in my eyes.$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; } );
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.
|
---|