Catman...::JSON(3pm)
π Catman...::JSON(3pm) π
okay bestie, so this is the manual page for Catman...::JSON, section 3pm β and the actual star of the show, the module itself, is Catmandu::Exporter::JSON. yes the page name and the module name are doing two different things, we love that for them, no notes. it's giving "user contributed perl documentation" energy and honestly? iconic. π
β¨ NAME β¨
Catmandu::Exporter::JSON β a JSON exporter. that's it, that's the whole name section, she's concise π
πΈ SYNOPSIS πΈ
okay so here's how you actually use her. three ways, all valid, all slay:
# 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;
my $exporter = Catmandu->exporter('JSON', fix => 'myfix.txt');
$exporter->add_many($arrayref);
$exporter->add_many($iterator);
$exporter->add_many(sub { });
$exporter->add($hashref);
printf "exported %d items\n" , $exporter->count;
like, add_many takes an arrayref, an iterator, or even a bare sub { } π«Ά and then you can flex with a little printf counting your items at the end. main character behaviour fr fr.
π¦ DESCRIPTION π¦
so basically: this Catmandu::Exporter exports your items serialized in JSON format. that's the vibe. π
and by default? every single item gets printed condensed onto one line. no sprawl, no drama, just tight little lines. periodt.
π CONFIGURATION π
here come the knobs and dials bestie, read carefully, there's a lot of them but they're all gonna eat:
fileβ write your output to a local file, given by its path or a file handle. OR, plot twist, you can pass a scalar reference to write into a string, or a code reference to write into a callback function. three doors, pick your fave πͺβ¨fhβ write the output to anIO::Handle. if you don't specify one,Catmandu::Util::iosteps in and creates the output handle from thefileargument, or just falls back to usingSTDOUT. she's resourceful πfixβ an ARRAY of one or more fixes or file scripts that get applied to your exported items. glow-up your data on the way out, we love a transformation arc π§encodingβ the binmode of the output streamfh. defaults to":utf8". keep it cute, keep it utf8 πprettyβ pretty-print that JSON. make it look good for the timeline β¨indent,space_before,space_after,canonicalβ these are your JSON serialization options. the formatting squad, all four of them, grouped together, doing their little formatting things πarrayβ structure the data as a JSON array. default is1. so yeah, array mode is the factory setting πline_delimitedβ export items as newline delimited JSON. default is0.
β οΈ okay important bestie, listen: ifline_delimitedis1, thenarray,pretty,indent,space_beforeandspace_afterall get ignored. like, completely. they're standing outside the club. so don't come for me when yourprettydoes nothing, i warned you π
π SEE ALSO π
Catmandu::Exporter::YAMLβ the sibling, the other format, the parallel universe version of this whole situation π¦
and that's the whole page bestie!! this gem is perl v5.40.1 and this documentation is dated 2026-01-24. mwah, go export something gorgeous ππ β¨
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms