1Test::JSON(3)         User Contributed Perl Documentation        Test::JSON(3)
2
3
4

NAME

6       Test::JSON - Test JSON data
7

VERSION

9       Version 0.11
10

SYNOPSIS

12        use Test::JSON;
13
14        is_valid_json $json,                 '... json is well formed';
15        is_json       $json, $expected_json, '... and it matches what we expected';
16

EXPORT

18       ·   is_valid_json
19
20       ·   is_json
21

DESCRIPTION

23       JavaScript Object Notation (JSON) is a lightweight data interchange
24       format.  Test::JSON makes it easy to verify that you have built valid
25       JSON and that it matches your expected output.
26
27       See <http://www.json.org/> for more information.
28

TESTS

30   is_valid_json
31        is_valid_json $json, '... json is well formed';
32
33       Test passes if the string passed is valid JSON.
34
35   is_json
36        is_json $json, $expected_json, '... and it matches what we expected';
37
38       Test passes if the two JSON strings are valid JSON and evaluate to the
39       same data structure.
40
41       Test::Differences is used to provide easy diagnostics of why the JSON
42       structures did not match.  For example:
43
44          Failed test '... and identical JSON should match'
45          in t/10testjson.t at line 14.
46        +----+---------------------------+---------------------------+
47        | Elt|Got                        |Expected                   |
48        +----+---------------------------+---------------------------+
49        |   0|{                          |{                          |
50        |   1|  bool => '1',             |  bool => '1',             |
51        |   2|  description => bless( {  |  description => bless( {  |
52        |   3|    value => undef         |    value => undef         |
53        |   4|  }, 'JSON::NotString' ),  |  }, 'JSON::NotString' ),  |
54        |   5|  id => '1',               |  id => '1',               |
55        *   6|  name => 'foo'            |  name => 'fo'             *
56        |   7|}                          |}                          |
57        +----+---------------------------+---------------------------+
58

AUTHOR

60       Curtis "Ovid" Poe, "<ovid@cpan.org>"
61

BUGS

63       Please report any bugs or feature requests to
64       "bug-test-json@rt.cpan.org", or through the web interface at
65       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-JSON>.  I will be
66       notified, and then you'll automatically be notified of progress on your
67       bug as I make changes.
68

SEE ALSO

70       This test module uses JSON::Any and Test::Differences.
71

ACKNOWLEDGEMENTS

73       The development of this module was sponsored by Kineticode,
74       <http://www.kineticode.com/>, the leading provider of services for the
75       Bricolage content management system, <http://www.bricolage.cc/>.
76
77       Thanks to Makamaka Hannyaharamitu "makamaka@cpan.org" for a patch to
78       make this work with JSON 2.0.
79
80       Thanks to Stevan Little for suggesting a switch to JSON::Any.  This
81       makes it easier for this module to work with whatever JSON module you
82       have installed.
83
85       Copyright 2005-2007 Curtis "Ovid" Poe, all rights reserved.
86
87       This program is free software; you can redistribute it and/or modify it
88       under the same terms as Perl itself.
89
90
91
92perl v5.32.0                      2020-07-28                     Test::JSON(3)
Impressum