JSON_PP(1perl)
π json_pp β the manual, but make it make sense π
okay bestie, sit down, hydrate, because we're talking about json_pp, the little command-line icon from the JSON::PP family. This page lives in the Perl Programmers Reference Guide section of the manual, section 1perl. Yes, that means it's a user command. Yes, that means you can literally just run it. Slay. π
β¨ NAME β¨
json_pp β the JSON::PP command utility. that's it, that's the whole name. short, sweet, does exactly what it says on the tin. π¦
β¨ SYNOPSIS β¨
the vibe check, in one line:
json_pp [-v] [-f from_format] [-t to_format] [-json_opt options_to_json1[,options_to_json2[,...]]]
that's the shape of it. flags, a from-format, a to-format, some JSON::PP options. we love a predictable girlie. π
β¨ DESCRIPTION β¨
so here's the tea β β json_pp converts between some input and output formats, and yeah, one of those formats is JSON (obviously, it's in the name, the main character energy is off the charts).
fun fact for the lore girlies: this program was copied from json_xs and then modified. glow-up era. β¨
Default behaviour, because defaults matter:
- the default input format is
json - the default output format is
jsonwith theprettyoption
so if you just piped something in and didn't say anything else, it'd come out pretty-printed. thoughtful queen. π
β¨ OPTIONS β¨
π -f
-f from_format
Reads a data in the given format from STDIN. (Yes, it's reading from STDIN. Pipe it in, bestie.)
Format types you can hand it:
jsonβ as JSONevalβ as Perl code
two options, both iconic, pick your fighter. π
π -t
Writes a data in the given format to STDOUT.
Format types:
nullβ no action.jsonβ as JSONdumperβ as Data::Dumper
(null being a valid output format that does literally nothing is so real of it ngl π)
π -json_opt
options to JSON::PP. let's go, this is the big one.
Acceptable options are:
ascii latin1 utf8 pretty indent space_before space_after relaxed canonical allow_nonref
allow_singlequote allow_barekey allow_bignum loose escape_slash indent_length
π¨ the one rule, bestie, don't mess this up: Multiple options must be separated by commas.
Right: -json_opt pretty,canonical
Wrong: -json_opt pretty -json_opt canonical
like. the comma matters. the comma is the whole girl. fr fr. commas are doing the heavy lifting and the second version is NOT it. π«Ά
π -v
Verbose option, but currently no action in fact. π
(not me expecting verbose output and getting absolutely nothing β she's cosplaying as a real flag out here.)
π -V
Prints version and exits. this one actually works, king behaviour. β
β¨ EXAMPLES β¨
here's where it gets good. watch what happens with a big ol' number and some Japanese text in the mix. πΈ
First up, with pretty,utf8,allow_bignum:
$ perl -e'print q|{"foo":"γγ","bar":1234567890000000000000000}|' |\
json_pp -f json -t dumper -json_opt pretty,utf8,allow_bignum
$VAR1 = {
'bar' => bless( {
'value' => [
'0000000',
'0000000',
'5678900',
'1234'
],
'sign' => '+'
}, 'Math::BigInt' ),
'foo' => "\x{3042}\x{3044}"
};
see how the big number got blessed into a Math::BigInt? that's the allow_bignum working. and foo came out as proper characters. ate. π₯
Then the exact same input, but with just pretty:
$ perl -e'print q|{"foo":"γγ","bar":1234567890000000000000000}|' |\
json_pp -f json -t dumper -json_opt pretty
$VAR1 = {
'bar' => '1234567890000000000000000',
'foo' => "\x{e3}\x{81}\x{82}\x{e3}\x{81}\x{84}"
};
and now the number is just a plain string, and the text is a pile of escaped bytes. same input, different flags, completely different glow. the way that -json_opt changes everythingβ¦ it's giving control freak in the best way. π
β¨ SEE ALSO β¨
go read these next, bestie, do it for me:
JSON::PPjson_xs
β¨ AUTHOR β¨
Makamaka Hannyaharamitu, <makamaka[at]cpan.org> β thank you for your service, legend π«Ά
β¨ COPYRIGHT AND LICENSE β¨
Copyright 2010 by Makamaka Hannyaharamitu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. (yes, the classic Perl-itself clause. free as in freedom, we love to see it. π)
okay that's the whole page!! π¦ and for the cute sign-off: this beauty is from perl v5.44.0, dated 2026-10-17, filed under JSON_PP(1perl). go forth and pretty-print something. periodt. π
β¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND 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