JSON_PP(1p)
π JSON_PP(1p) π
okay bestie, listen up β this is json_pp, a sweet little command utility from JSON::PP, and it lives in the User Contributed Perl Documentation corner of your perl install π
she's giving "tiny tool, big main character energy" and honestly? obsessed.
β¨ NAME β¨
json_pp β the JSON::PP command utility π
β¨ SYNOPSIS β¨
json_pp [-v] [-f from_format] [-t to_format] [-json_opt options_to_json1[,options_to_json2[,...]]]
β¨ DESCRIPTION β¨
so what does she even do?? json_pp converts between some input and output formats β and yep, one of them is JSON π¦ she came into this world by being copied from json_xs and then modified, so like... glow-up, respectfully π
the default input format is json, and the default output format is json with the pretty option. default behavior is already cute, no cap β¨
β¨ OPTIONS β¨
πΈ -f
-f from_format
reads your data in the given format, straight from STDIN π₯
the format types you can pass:
jsonβ as JSON βevalβ as Perl code π
πΈ -t
writes your data in the given format out to STDOUT π«
the format types you can pass:
nullβ no action, literally does nothing, she's resting πjsonβ as JSONdumperβ as Data::Dumper π§
πΈ -json_opt
options that get handed to JSON::PP β¨
the acceptable options are, exactly these:
ascii latin1 utf8 pretty indent space_before space_after relaxed canonical allow_nonref
allow_singlequote allow_barekey allow_bignum loose escape_slash indent_length
if you're passing multiple options, you have to separate them with commas β no exceptions, bestie:
Right: -json_opt pretty,canonical
Wrong: -json_opt pretty -json_opt canonical
π¨ like... right is right and wrong is wrong. comma-separated = slay. repeating the flag = not it. periodt π
πΈ -v
the verbose option π but ngl, currently it does no action in fact. she's decorative. she's there for the vibe. she's not doing anything and that's okay π«Ά
πΈ -V
prints the version and exits π short, sweet, efficient.
π EXAMPLES π
first up, big-number girlie with allow_bignum β watch her bless that into a Math::BigInt like the icon she is π
$ 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}"
};
and then the same thing without allow_bignum β now she's just a plain string, and the utf8 comes out as raw bytes π same input, different era:
$ 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}"
};
π SEE ALSO π
JSON::PP, json_xs β go read those too, bestie, they're the whole lore π¦
π AUTHOR π
Makamaka Hannyaharamitu, <makamaka[at]cpan.org> πΈ (ty for your service, king)
π 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 π
and that's the whole page, bestie!! π this one's running on perl v5.38.2, dated 2024-08-07, and it's filed under JSON_PP(1p) in the perl manpages π go forth and pretty-print responsibly, iykyk β¨π¦π
π¦ where this page comes from
- debian trixie: libjson-pp-perl 4.16000-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libjson-pp-perl 4.16000-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libjson-pp-perl 4.16000-2 Β· 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