Test2:...::JSON(3pm)

✨ NAME ✨

okay so this is Test2::Harness::Util::JSON (the page header calls it Test2:...::JSON(3pm), cute abbreviated moment πŸ’…) β€” it's a utility class that helps Test2::Harness pick the best JSON implementation to use. bestie, it's literally the vibe-checker for your JSON backend πŸŽ€


🌸 DESCRIPTION 🌸

This package hands you functions for encoding/decoding json, and it uses the best json tools that are available. no cap. it doesn't make you choose β€” it just picks the good one and slays πŸ¦‹


πŸ’– SYNOPSIS πŸ’–

use Test2::Harness::Util::JSON qw/encode_json decode_json/;

my $data = { foo => 1 };
my $json = encode_json($data);
my $copy = decode_json($json);

so you import encode_json and decode_json, shove your data in, and get a string out. then you can turn that string back into data. it's giving round trip ✨


πŸ‘‘ EXPORTS πŸ‘‘

here's everything you can pull into your namespace, one by one, no skips 🫢

  • $package = JSON() β€” gives you back the JSON package that yath is actually using. like, the real one. the main character πŸ”₯
  • $bool = JSON_IS_PP() β€” true if yath is using JSON::PP.
  • $bool = JSON_IS_XS() β€” true if yath is using JSON::XS.
  • $bool = JSON_IS_CPANEL() β€” true if yath is using Cpanel::JSON::XS.
  • $bool = JSON_IS_CPANEL_OR_XS() β€” true if either JSON::XS or Cpanel::JSON::XS are being used. either/or energy, we love to see it πŸ’œ
  • $string = encode_json($data) β€” encodes data into json. the string will be 1-line. compact. efficient. lowkey neat πŸ“
  • $data = decode_json($string) β€” decodes json data out of the string. turn that text back into vibes ⭐
  • $string = encode_pretty_json($data) β€” encodes into human-friendly json. pretty-printed, easy on the eyes, screenshot-worthy πŸŽ€
  • $string = encode_canon_json($data) β€” encodes into canon-json. canonical, periodt πŸ‘‘

πŸ” SOURCE πŸ”

the source code repository for Test2-Harness lives at http://github.com/Test-More/Test2-Harness/ β€” go peek, bestie, the receipts are all there πŸ™ˆ


πŸ’… MAINTAINERS πŸ’…

  • Chad Granum <exodist@cpan.org>

🌈 AUTHORS 🌈

  • Chad Granum <exodist@cpan.org>

Copyright 2020 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/


ngl the licensing is short and sweet: same terms as Perl itself, fr fr. go read the link if you wanna know the details πŸ’€

and that's the whole page, bestie 🫢 this was perl v5.40.1, dated 2026-05-10 β€” that's the version and date stamped on this little icon, so now you know exactly which era of energy you're working with. mwah πŸ’–βœ¨

πŸ“¦ where this page comes from