I have trouble parsing a json object with perl and I don't know if the issue is coming from the json or my script. Here is the json:
test.json
{
"count":3,
"entries":
[
{
"id":85,
"application":AuditExampleLogin1,
"user":admin,
"time":"2011-11-22T10:29:37.422Z",
"values":
null
},
{
"id":87,
"application":AuditExampleLogin1,
"user":admin,
"time":"2011-11-22T10:30:56.235Z",
"values":
null
},
{
"id":89,
"application":AuditExampleLogin1,
"user":admin,
"time":"2011-11-22T10:33:15.000Z",
"values":
null
}
]
}
Here the script:
script.pl
#!/usr/bin/perl -w
use strict;
use JSON;
open FILE, 'test.json' or die "Could not open file inputfile: $!";
sysread(FILE, my $result, -s FILE);
close FILE or die "Could not close file: $!";
my @json = @{decode_json($result)};
And finally the error I'm getting:
error
malformed JSON string, neither array, object, number, string or atom,
at character offset 86 (before "AuditExampleLogin1,\n...") at
./script.pl line 7.
Q: Can someone tell me whether the issue is coming from the json or my script and what to change in either case?