NAME
Catmandu::Importer::JSON - Package that imports JSON data
SYNOPSIS
use Catmandu::Importer::JSON;
my $importer = Catmandu::Importer::JSON->new(file => "/foo/bar.json");
my $n = $importer->each(sub {
my $hashref = $_[0];
# ...
});
The defaults assume a newline delimited JSON file:
{ "recordno": 1, "name": "Alpha" }
{ "recordno": 2, "name": "Beta" }
{ "recordno": 3, "name": "Gamma" }
Use the multiline
option to parse pretty-printed JSON or JSON arrays.
METHODS
new([file => $filename, multiline => 0|1])
Create a new JSON importer for $filename
. Uses STDIN when no filename is given. multiline
switches between line-delimited JSON and multiline JSON or arrays. the default is line-delimited JSON.
count
each(&callback)
...
Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. The Catmandu::Importer::JSON methods are not idempotent: JSON streams can only be read once.