The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Catmandu::Exporter::JSON - a JSON exporter

SYNOPSIS

Command line interface:

    catmandu convert YAML to JSON --pretty 1 < input.yml

In Perl code:

    use Catmandu -all;

    my $exporter = exporter('JSON', fix => 'myfix.txt');

    $exporter->add_many($arrayref);
    $exporter->add_many($iterator);
    $exporter->add_many(sub { });

    $exporter->add($hashref);

    printf "exported %d objects\n" , $exporter->count;

DESCRIPTION

This Catmandu::Exporter exports items serialized in JSON format. By default each item is printed condensed on one line.

CONFIGURATION

file

Write output to a local file given by its path or file handle. Alternatively a scalar reference can be passed to write to a string and a code reference can be used to write to a callback function.

fh

Write the output to an IO::Handle. If not specified, Catmandu::Util::io is used to create the output handle from the file argument or by using STDOUT.

fix

An ARRAY of one or more fixes or file scripts to be applied to exported items.

encoding

Binmode of the output stream fh. Set to ":utf8" by default.

pretty
multiline

Pretty-print JSON

indent
space_before
space_after
canonical

JSON serialization options

array

Seralize items as one JSON array instead of concatenated JSON objects

SEE ALSO

Catmandu::Exporter::YAML