JSON_PP(1p)

πŸ“¦
version 4.16000 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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 JSON
  • dumper β€” 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 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