Latest JSON::Parse (mine is 0.40) has a warn_only() function which does supposedly not let program die but return undef.
How do I use this feature?
use JSON::Parse;
my $JP = JSON::Parse->new();
$JP->warn_only();
$JP->warn_only(1);
or even
JSON::Parse->warn_only($JP, 'on');
it gives me:
Usage: JSON::Parse::warn_only(parser, onoff)
or:
JSON::Parse::warn_only: parser is not of type JSON::Parse
EDIT:
note: the following does not complain but has no effect i can notice of.
$j->warn_only(1);
Below is a perl snippet to demonstrate the issue:
use strict;
use warnings;
use JSON::Parse 0.38;
use Data::Dumper;
my $j = JSON::Parse->new();
# no complain, no effect:
$j->warn_only(1);
# legal json:
my $pl = $j->run('{"k":"v"}');
print Dumper($pl);
print "I am not dead 1\n";
# illegal json, the following statement dies:
$pl = $j->run('illegal json');
print Dumper($pl);
print "I am not dead 2\n";
Results:
$VAR1 = {
'k' => 'v'
};
I am not dead 1
JSON error at line 1, byte 1/12: blah blah blah at which point it has
+died.
many thanks monks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.