NAME
Test::JSON::Assert - Tests JPaths into an JSON Data structure for correct values/matches
SYNOPSIS
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>";
ToDo
DESCRIPTION
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.
SUBROUTINES
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.
- is_jpath_count($doc, $jpath, $count, $name)
-
Test passes if there are $count keys referenced by $jpath in the $doc.
$count
is the number of expected keys which match the$jpath
. - does_jpath_value_match($doc, $jpath, $match, $name)
-
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. - do_jpath_values_match($doc, $jpath, $match, $name)
-
Test passes if
$jpath
matches at least one key in$doc
and all nodes matched smart matches against$match
.Again,
$match
can be a scalar, regex, arrayref or anything the smart match operator can match on. - does_jpath_contains($doc, $jpath, $match, $name)
-
Test passes if
$jpath
contains a key in$doc
that matches against$match
.Again,
$match
can be a scalar, regex, arrayref.
EXPORTS
Everything in "SUBROUTINES" by default, as expected.
SEE ALSO
JSON::Assert, XML::Assert, XML::Compare, Test::Builder
AUTHOR
- Work
-
<puck at catalyst dot net dot nz>, http://www.catalyst.net.nz/
- Personal
-
<andrew at etc dot gen dot nz<gt>, http://www.etc.gen.nz/
COPYRIGHT & LICENSE
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.