所以我试图加载测试REST API,它返回一个JSON值.
为此,我创建了perl脚本的多个实例.
Perl脚本基本上调用该URL,并尝试decode_json.显然,当产生大量负载时,它会失败.
现在我面临的问题是 - 命令提示符上显示错误,但不会在文件中写入该错误消息.
错误消息是
malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "Can't connect to 209...") at json_load_test.pl line 39.
在第39行以下的所有三次尝试中,指的是:
decode_json($actual_response);
Run Code Online (Sandbox Code Playgroud)
我只是在命令提示符下运行脚本:
perl json_load_test.pl >> logs/output.txt
Run Code Online (Sandbox Code Playgroud)
我期待在"output.txt"中写下错误消息
我的三次失败尝试如下.
my $ua = LWP::UserAgent->new;
$ua->timeout(3);
$ua->env_proxy;
my $response = $ua->get("http://$j_env/jobs/all.json?status=active");
my $actual_response=$response->decoded_content;
decode_json($actual_response);
if ($? == -1)
{print "\n Failed to execute: $!\n"; }
Run Code Online (Sandbox Code Playgroud)
my $ua = LWP::UserAgent->new;
$ua->timeout(3);
$ua->env_proxy;
my $response …Run Code Online (Sandbox Code Playgroud)