s*******y 发帖数: 558 | 1 现在我用JSON module里面的from_json function。 但是如果input string不是valid
JSON string, 整个程序就die掉了。
how to skip this input string if it is not a valid json string?
Thanks a lot | j*****a 发帖数: 436 | 2 Try to use eval to catch the errors from the function, for example:
eval {
$parsed = from_json( $text, $flag );
};
if ($@) {
print "from_json ERROR\n";
}
else {
print "OK\n";
}
| a***y 发帖数: 2803 | 3 cpan.org上查.
valid
【在 s*******y 的大作中提到】 : 现在我用JSON module里面的from_json function。 但是如果input string不是valid : JSON string, 整个程序就die掉了。 : how to skip this input string if it is not a valid json string? : Thanks a lot
|
|