Catman...::JSON(3pm)
π Catman...::JSON(3pm) π
okay bestie, gather round π«Ά this is a page from the User Contributed Perl Documentation set, and it's all about Catmandu::Importer::JSON β yes the manpage header is literally Catman...::JSON(3pm), we don't make the rules, we just slay within them β¨
πΈ NAME πΈ
Catmandu::Importer::JSON β the package that imports JSON data. that's it, that's the whole job, and it does it gorgeously π
β¨ SYNOPSIS β¨
so here's how you'd actually use it. from the command line, like a main character:
# From the command line
$ catmandu convert JSON to YAML < data.json
# or for faster newline delimited input
$ catmandu convert JSON --line_delimited 1 to YAML < data.json
and if you're in a Perl script (iykyk), it's giving:
# In a Perl script
use Catmandu;
my $importer = Catmandu->importer('JSON', file => "/foo/bar.json");
my $n = $importer->each(sub {
my $hashref = $_[0];
# ...
});
obsessed. genuinely. π
π¦ DESCRIPTION π¦
this package imports JSON data, no cap. and the parser? it's quite liberal in the input it accepts β it's not gonna gatekeep your JSON, it'll just take it π«Ά
and if you want speed, you can use the line_delimited option to parse "newline delimited JSON" faster. here's the vibe:
{ "recordno": 1, "name": "Alpha" }
{ "recordno": 2, "name": "Beta" }
{ "recordno": 3, "name": "Gamma" }
one object per line, no commas, no drama. slay β¨
π CONFIGURATION π
the way each of these options is literally a whole personality:
fileβ read input from a local file, given by its path. or, plot twist, you can pass a scalar reference instead and it'll read from a string πfhβ read input from anIO::Handle. if you don't specify it,Catmandu::Util::iogets called in to create the input stream from thefileargument, or by usingSTDIN. it's got you either way πencodingβ the binmode of the input streamfh. it's set to:utf8by default, as a treat πfixβ anARRAYof one or more fixes or file scripts to be applied to the imported items. glow-up your data on the way in, periodt πline_delimitedβ read line-delimited JSON line-by-line with a non-incremental parser. fast mode unlocked π₯byte_buffer_sizeβ how many bytes get read by each iteration of the incremental parser. ignored ifline_delinmitedis 1 (yes that spelling is in the original, bestie, we report what we see, no editing the source π). default is256.
π METHODS π
every Catmandu::Importer is a Catmandu::Iterable, and all its methods are inherited. so like, you get the whole family tree π³
but here's the tea, and it's important tea: the methods are not idempotent. JSON streams can only be read once. read it once and it's gone, like a limited-edition drop. don't come back asking for seconds π
π SEE ALSO π
Catmandu::Exporter::JSONβ the other half of the love story π«Ά
and that's the whole page, bestie!! π this was Catman...::JSON(3pm) from the User Contributed Perl Documentation, living in perl v5.40.1 and dated 2026-01-24. go import some JSON, you absolute icon πβ¨
π¦ 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