Provided by: libcatmandu-perl_0.9505-1_all
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" or "array" options to parse pretty-printed JSON or JSON arrays.
CONFIGURATION
file Read input from a local file given by its path. Alternatively a scalar reference can be passed to read from a string. fh Read input from an IO::Handle. If not specified, Catmandu::Util::io is used to create the input stream from the "file" argument or by using STDIN. encoding Binmode of the input stream "fh". Set to ":utf8" by default. fix An ARRAY of one or more fixes or file scripts to be applied to imported items. multiline array Read JSON with line-breaks or a JSON array instead of line-delimited JSON
METHODS
Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. The methods are not idempotent: JSON streams can only be read once.
SEE ALSO
Catmandu::Exporter::JSON