Test::JSON::Assert - Tests JPaths into an JSON Data structure for correct values/matches
use Test::JSON::Assert tests => 2;
my $xml1 = "<foo xmlns="urn:message"><bar baz="buzz">text</bar></foo>";
my $xml2 = "<f:foo xmlns:f="urn:message"><f:bar baz="buzz">text</f:bar></f:foo>";
my $xml3 = "<foo><bar baz="buzz">text</bar></foo>";
This module allows you to test if two JSON data structures are semantically the same.
It uses JSON::Assert to do all of it's checking.
In all of the following subroutines there are three common parameters.
$doc is a data structure generated from a JSON document.
$jpath is a string which contains the path to the element(s) you'd like to match against, whether this is for a count or a value match.
Test passes if there are $count keys referenced by $jpath in the $doc.
$count is the number of expected keys which match the $jpath.
Test passes if $jpath matches only one key in $doc and the value matched smart matches against $match.
Again, $match can be a scalar, regex, arrayref or anything the smart match operator can match on.
Test passes if $jpath matches at least one key in $doc and all nodes matched smart matches against $match.
Test passes if $jpath contains a key in $doc that matches against $match.
Again, $match can be a scalar, regex, arrayref.
Everything in "SUBROUTINES" by default, as expected.
JSON::Assert, XML::Assert, XML::Compare, Test::Builder
<puck at catalyst dot net dot nz>, http://www.catalyst.net.nz/
<andrew at etc dot gen dot nz<gt>, http://www.etc.gen.nz/
This software development is sponsored and directed by NZRS Ltd., http://www.nzrs.net.nz/
Part of work was carried out by Catalyst IT, http://www.catalyst.net.nz/
Copyright (c) 2014-2015, NZRS Limited. All Rights Reserved. This software may be used under the terms of the Artistic License 2.0. Note that this license is compatible with both the GNU GPL and Artistic licenses. A copy of this license is supplied with the distribution in the file COPYING.txt.
To install JSON::Assert, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.