Catmandu::Exporter::JSON - a JSON exporter
# From the command line catmandu convert YAML to JSON --pretty 1 < input.yml # Export in the line-delimited format catmandu convert YAML to JSON --line_delimited 1 < input.yml # In a Perl script 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;
This Catmandu::Exporter exports items serialized in JSON format. By default each item is printed condensed on one line.
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.
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.
file
An ARRAY of one or more fixes or file scripts to be applied to exported items.
Binmode of the output stream fh. Set to ":utf8" by default.
fh
:utf8
Pretty-print JSON
JSON serialization options
Structure the data as a JSON array. Default is 1.
1
Export objects as newline delimited JSON. Default is 0. The array, pretty, indent, space_before and space_after options will be ignored if line_delimited is 1.
0
array
pretty
indent
space_before
space_after
line_delimited
Catmandu::Exporter::YAML
To install Catmandu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catmandu
CPAN shell
perl -MCPAN -e shell install Catmandu
For more information on module installation, please visit the detailed CPAN module installation guide.