Test::Deep::JSON(3pm)
π Test::Deep::JSON π
okay bestie, so this is Test::Deep::JSON β it's the little module that lets you compare JSON with Test::Deep. yes. that's the whole vibe. it's giving "match my JSON without me hand-writing a parser", and honestly? obsessed. π¦
β¨ SYNOPSIS β¨
use Test::Deep;
use Test::Deep::JSON;
cmp_deeply {
foo => 'bar',
payload => '{"a":1}',
}, {
foo => 'bar',
payload => json({ a => ignore() }),
};
see how clean that is?? no cap. you got a raw JSON string sitting in payload, and instead of losing your mind trying to decode-and-compare it yourself, you just wrap your expectations in json(...) and let the module handle the rest. main character energy fr fr. π
πΈ DESCRIPTION πΈ
Test::Deep::JSON hands you the json($expected) function, and what it does is: it expects that your target can be parsed as a JSON string and that it matches $expected β and the matching itself happens via cmp_deeply. literally that's it, that's the function, and it ate. π
π FUNCTIONS π
json($expected)β the one and only, bestie.
This one is exported by default, so it just shows up in your namespace the moment you use Test::Deep::JSON;. no extra ceremony, we love a low-maintenance queen. π«Ά
$expected can be anything that Test::Deep recognizes β like, whatever fancy comparison stuff you'd normally throw at Test::Deep? it's valid in here too. go wild. π
What happens under the hood: this parses the data as a JSON string, then compares the parsed object against $expected using Test::Deep functionality. so you're comparing real decoded structures, not vibes. π
and if the data cannot be parsed as a JSON string? it fails. periodt. it will not pretend, it will not let it slide, it will simply not pass. π
π AUTHOR π
motemen <motemen@gmail.com>
π¦ SEE ALSO π¦
Test::Deep
π LICENSE π
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so like, go forth and remix, queen. πΈ
okay and one last thing before you go β this whole page came to you courtesy of perl v5.36.0, dated 2022-12-12, and the page itself is Test::Deep::JSON(3pm). mwah. happy testing bestie, go write some immaculate assertions πβ¨π§
π¦ where this page comes from
- debian bookworm: libtest-deep-json-perl 0.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-deep-json-perl 0.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-deep-json-perl 0.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-deep-json-perl 0.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-deep-json-perl 0.05-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