JSON_PP(1)

๐ŸŒธ NAME ๐ŸŒธ

okay so bestie, welcome to json_pp โ€” the JSON::PP command utility, living its best life in section 1 of the Perl Programmers Reference Guide. She converts stuff between formats and she ate, no cap ๐Ÿ’…


โœจ SYNOPSIS โœจ

json_pp [-v] [-f from_format] [-t to_format] [-json_opt options_to_json1[,options_to_json2[,...]]]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So json_pp converts between some input and output formats โ€” and yes, one of them is JSON (the main character, obvi) ๐Ÿ’– This program was copied from json_xs and then modified, so she's got lore. Ngl, she's basically json_xs's little sister and she's thriving.

The default input format is json and the default output format is json with the pretty option. So if you just pipe something in with zero flags, she'll hand you back gorgeous pretty-printed JSON like it's nothing ๐ŸŽ€


๐ŸŽ€ OPTIONS ๐ŸŽ€

-f

  • -f from_format โ€” reads your data in the given format from STDIN. That's the input side of the story, bestie.

Format types you can pick from:

  • json โ€” as JSON ๐Ÿงš
  • eval โ€” as Perl code

-t

  • -t โ€” writes your data in the given format to STDOUT. Output side, let's go.

Format types:

  • null โ€” no action. Like, literally nothing happens. She's on break ๐Ÿ’€
  • json โ€” as JSON โญ
  • dumper โ€” as Data::Dumper

-json_opt

  • -json_opt โ€” options to JSON::PP. This is where you customise the vibe โœจ

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

Multiple options must be separated by commas. This is so important:

Right: -json_opt pretty,canonical

Wrong: -json_opt pretty -json_opt canonical
fr fr, do not repeat the flag. Comma-separate them or she will not be happy with you ๐Ÿ˜ญ

-v

  • -v โ€” the verbose option, but currently no action in fact. She's giving "I'm here for moral support" energy. Iconic of her honestly ๐Ÿ™ˆ

-V

  • -V โ€” prints the version and exits. Short and sweet, a true queen ๐Ÿ‘‘

๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

Here's our first slay โ€” note the allow_bignum doing its absolute thing:

$ 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 option carrying the whole team ๐Ÿซถ

Now the same input, but without allow_bignum โ€” watch what happens to our giant number:

$ 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}"
        };

Yeah โ€” the number stays a plain string and the string gets escaped. Different vibe entirely, lowkey fascinating ๐Ÿ‘€


๐Ÿ’œ SEE ALSO ๐Ÿ’œ

  • JSON::PP
  • json_xs

Go read those next, bestie, they're the extended universe ๐ŸŒˆ


๐ŸŒŸ AUTHOR ๐ŸŒŸ

Makamaka Hannyaharamitu, <makamaka[at]cpan.org>


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.


okay that's the whole page, you're officially caught up ๐Ÿ’– this was json_pp(1) from the Perl Programmers Reference Guide, brought to you by perl v5.42.3 and dated 2026-11-03 โ€” go forth and pretty-print, bestie, mwah ๐ŸŽ€โœจ๐Ÿ’…

๐Ÿ“ฆ where this page comes from