<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Test::JSON::Type - Test JSON data with types.

SYNOPSIS
     use Test::JSON::Type;

     is_json_type($json, $json_expected, $test_name);
     is_json_type_struct($json, $expected_type_hr, $test_name);

SUBROUTINES
  "is_json_type"
     is_json_type($json, $json_expected, $test_name);

    This decodes $json and $json_expected JSON strings to Perl structure and
    return data type structure defined by Cpanel::JSON::XS::Type. And
    compare these structures, if are same.

    Result is success or failure of this comparison. In case of failure
    print difference in test.

  "is_json_type_struct"
     is_json_type_struct($json, $expected_type_hr, $test_name);

    This decoded $json JSON string to Perl structure and return data type
    structure defined by Cpanel::JSON::XS::Type. Compare this structure with
    $expected_type_hr, if are same.

    Result is success or failure of this comparison. In case of failure
    print difference in test.

ERRORS
     is_json_type():
             JSON string isn't valid.
                     Error: %s
             JSON string to compare is required.
             Expected JSON string isn't valid.
                     Error: %s
             Expected JSON string to compare is required.
     is_json_type_struct():
             JSON string isn't valid.
                     Error: %s
             JSON string to compare is required.

EXAMPLE1
     use strict;
     use warnings;

     use Test::JSON::Type;
     use Test::More 'tests' =&gt; 2;

     my $json_blank1 = '{}';
     my $json_blank2 = '{}';
     is_json_type($json_blank1, $json_blank2, 'Blank JSON strings.');

     my $json_struct1 = &lt;&lt;'END';
     {
       "bool": true,
       "float": 0.23,
       "int": 1,
       "null": null,
       "string": "bar"
     }
     END
     my $json_struct2 = &lt;&lt;'END';
     {
       "bool": false,
       "float": 1.23,
       "int": 2,
       "null": null,
       "string": "foo"
     }
     END
     is_json_type($json_struct1, $json_struct2, 'Structured JSON strings.');

     # Output:
     # 1..2
     # ok 1 - Blank JSON strings.
     # ok 2 - Structured JSON strings.

EXAMPLE2
     use strict;
     use warnings;

     use Test::JSON::Type;
     use Test::More 'tests' =&gt; 1;

     my $json_struct_err1 = &lt;&lt;'END';
     {
       "int": 1,
       "string": "1"
     }
     END
     my $json_struct_err2 = &lt;&lt;'END';
     {
       "int": 1,
       "string": 1
     }
     END
     is_json_type($json_struct_err1, $json_struct_err2, 'Structured JSON strings with error.');

     # Output:
     # 1..1
     # not ok 1 - Structured JSON strings with error.
     # #   Failed test 'Structured JSON strings with error.'
     # #   at ./ex2.pl line 21.
     # # +----+--------------------------------+-----------------------------+
     # # | Elt|Got                             |Expected                     |
     # # +----+--------------------------------+-----------------------------+
     # # |   0|{                               |{                            |
     # # |   1|  int =&gt; 'JSON_TYPE_INT',       |  int =&gt; 'JSON_TYPE_INT',    |
     # # *   2|  string =&gt; 'JSON_TYPE_STRING'  |  string =&gt; 'JSON_TYPE_INT'  *
     # # |   3|}                               |}                            |
     # # +----+--------------------------------+-----------------------------+
     # # Looks like you failed 1 test of 1.

EXAMPLE3
     use strict;
     use warnings;

     use Test::JSON::Type;
     use Test::More 'tests' =&gt; 1;

     my $json_struct_err1 = &lt;&lt;'END';
     {
       "int": 1,
       "array": ["1", 1]
     }
     END
     my $json_struct_err2 = &lt;&lt;'END';
     {
       "int": 1,
       "array": 1
     }
     END
     is_json_type($json_struct_err1, $json_struct_err2, 'Structured JSON strings with error.');

     # Output:
     # 1..1
     # not ok 1 - Structured JSON strings with error.
     # #   Failed test 'Structured JSON strings with error.'
     # #   at ./ex3.pl line 21.
     # # +----+--------------------------+----+-----------------------------+
     # # | Elt|Got                       | Elt|Expected                     |
     # # +----+--------------------------+----+-----------------------------+
     # # |   0|{                         |   0|{                            |
     # # *   1|  array =&gt; [              *   1|  array =&gt; 'JSON_TYPE_INT',  *
     # # *   2|    'JSON_TYPE_STRING',   *    |                             |
     # # *   3|    'JSON_TYPE_INT'       *    |                             |
     # # *   4|  ],                      *    |                             |
     # # |   5|  int =&gt; 'JSON_TYPE_INT'  |   2|  int =&gt; 'JSON_TYPE_INT'     |
     # # |   6|}                         |   3|}                            |
     # # +----+--------------------------+----+-----------------------------+
     # # Looks like you failed 1 test of 1.

DEPENDENCIES
    Cpanel::JSON::XS, Cpanel::JSON::XS::Type, English, Error::Pure,
    Readonly, Test::Builder::Module, Test::Differences.

SEE ALSO
    Test::JSON
        Test JSON data

    Test::JSON::More
        JSON Test Utility

REPOSITORY
    &lt;https://github.com/michal-josef-spacek/Test-JSON-Type&gt;

AUTHOR
    Michal Josef Ĺ&nbsp;paÄŤek &lt;mailto:skim@cpan.org&gt;

    &lt;http://skim.cz&gt;

LICENSE AND COPYRIGHT
    Â© 2021-2022 Michal Josef Ĺ&nbsp;paÄŤek

    BSD 2-Clause License

VERSION
    0.03

</pre></body></html>