Test::Deep::JSON(3pm)

πŸ“¦
version 0.05 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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