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 JSON input file needs to include one record per line:

{ "recordno": 1, "name": "Alpha" }
{ "recordno": 2, "name": "Beta" }
{ "recordno": 3, "name": "Gamma" }

METHODS

new([file => $filename])

Create a new JSON importer for $filename. Use STDIN when no filename is given.

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.

SEE ALSO

Catmandu::Iterable