{"id":23771871,"url":"https://github.com/michal-josef-spacek/test-json-type","last_synced_at":"2026-05-14T21:32:48.625Z","repository":{"id":42676992,"uuid":"510327705","full_name":"michal-josef-spacek/Test-JSON-Type","owner":"michal-josef-spacek","description":"Test JSON data with types.","archived":false,"fork":false,"pushed_at":"2023-06-26T10:59:34.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-25T20:11:34.679Z","etag":null,"topics":["json","testing"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michal-josef-spacek.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"michal-josef-spacek"}},"created_at":"2022-07-04T11:16:12.000Z","updated_at":"2022-07-04T11:16:49.000Z","dependencies_parsed_at":"2025-05-25T20:20:34.208Z","dependency_job_id":null,"html_url":"https://github.com/michal-josef-spacek/Test-JSON-Type","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/michal-josef-spacek/Test-JSON-Type","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michal-josef-spacek%2FTest-JSON-Type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michal-josef-spacek%2FTest-JSON-Type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michal-josef-spacek%2FTest-JSON-Type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michal-josef-spacek%2FTest-JSON-Type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michal-josef-spacek","download_url":"https://codeload.github.com/michal-josef-spacek/Test-JSON-Type/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michal-josef-spacek%2FTest-JSON-Type/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261987837,"owners_count":23240919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","testing"],"created_at":"2025-01-01T04:46:37.983Z","updated_at":"2025-10-25T13:03:00.362Z","avatar_url":"https://github.com/michal-josef-spacek.png","language":"Perl","funding_links":["https://github.com/sponsors/michal-josef-spacek"],"categories":[],"sub_categories":[],"readme":"NAME\n    Test::JSON::Type - Test JSON data with types.\n\nSYNOPSIS\n     use Test::JSON::Type;\n\n     cmp_json_types($json, $json_expected, $test_name);\n     is_json_type($json, $expected_type_hr, $test_name);\n\nSUBROUTINES\n  \"cmp_json_types\"\n     cmp_json_types($json, $json_expected, $test_name);\n\n    This decodes $json and $json_expected JSON strings to Perl structure and\n    return data type structure defined by Cpanel::JSON::XS::Type. And\n    compare these structures, if are same.\n\n    Result is success or failure of this comparison. In case of failure\n    print difference in test.\n\n  \"is_json_type\"\n     is_json_type($json, $expected_type_hr, $test_name);\n\n    This decodes $json JSON string to Perl structure and encode with\n    expected JSON type $expected_type_hr. Compare these two JSON strings and\n    check if are same.\n\n    Result is success or failure of this comparison. In case of failure\n    print difference in test.\n\nERRORS\n     cmp_json_types():\n             JSON string isn't valid.\n                     Error: %s\n             JSON string to compare is required.\n             Expected JSON string isn't valid.\n                     Error: %s\n             Expected JSON string to compare is required.\n     is_json_type():\n             JSON string isn't valid.\n                     Error: %s\n             JSON string to compare is required.\n\nEXAMPLE1\n     use strict;\n     use warnings;\n\n     use Test::JSON::Type;\n     use Test::More 'tests' =\u003e 2;\n\n     my $json_blank1 = '{}';\n     my $json_blank2 = '{}';\n     cmp_json_types($json_blank1, $json_blank2, 'Blank JSON strings.');\n\n     my $json_struct1 = \u003c\u003c'END';\n     {\n       \"bool\": true,\n       \"float\": 0.23,\n       \"int\": 1,\n       \"null\": null,\n       \"string\": \"bar\"\n     }\n     END\n     my $json_struct2 = \u003c\u003c'END';\n     {\n       \"bool\": false,\n       \"float\": 1.23,\n       \"int\": 2,\n       \"null\": null,\n       \"string\": \"foo\"\n     }\n     END\n     cmp_json_types($json_struct1, $json_struct2, 'Structured JSON strings.');\n\n     # Output:\n     # 1..2\n     # ok 1 - Blank JSON strings.\n     # ok 2 - Structured JSON strings.\n\nEXAMPLE2\n     use strict;\n     use warnings;\n\n     use Test::JSON::Type;\n     use Test::More 'tests' =\u003e 1;\n\n     my $json_struct_err1 = \u003c\u003c'END';\n     {\n       \"int\": 1,\n       \"string\": \"1\"\n     }\n     END\n     my $json_struct_err2 = \u003c\u003c'END';\n     {\n       \"int\": 1,\n       \"string\": 1\n     }\n     END\n     cmp_json_types($json_struct_err1, $json_struct_err2, 'Structured JSON strings with error.');\n\n     # Output:\n     # 1..1\n     # not ok 1 - Structured JSON strings with error.\n     # #   Failed test 'Structured JSON strings with error.'\n     # #   at ./ex2.pl line 21.\n     # # +----+--------------------------------+-----------------------------+\n     # # | Elt|Got                             |Expected                     |\n     # # +----+--------------------------------+-----------------------------+\n     # # |   0|{                               |{                            |\n     # # |   1|  int =\u003e 'JSON_TYPE_INT',       |  int =\u003e 'JSON_TYPE_INT',    |\n     # # *   2|  string =\u003e 'JSON_TYPE_STRING'  |  string =\u003e 'JSON_TYPE_INT'  *\n     # # |   3|}                               |}                            |\n     # # +----+--------------------------------+-----------------------------+\n     # # Looks like you failed 1 test of 1.\n\nEXAMPLE3\n     use strict;\n     use warnings;\n\n     use Test::JSON::Type;\n     use Test::More 'tests' =\u003e 1;\n\n     my $json_struct_err1 = \u003c\u003c'END';\n     {\n       \"int\": 1,\n       \"array\": [\"1\", 1]\n     }\n     END\n     my $json_struct_err2 = \u003c\u003c'END';\n     {\n       \"int\": 1,\n       \"array\": 1\n     }\n     END\n     cmp_json_types($json_struct_err1, $json_struct_err2, 'Structured JSON strings with error.');\n\n     # Output:\n     # 1..1\n     # not ok 1 - Structured JSON strings with error.\n     # #   Failed test 'Structured JSON strings with error.'\n     # #   at ./ex3.pl line 21.\n     # # +----+--------------------------+----+-----------------------------+\n     # # | Elt|Got                       | Elt|Expected                     |\n     # # +----+--------------------------+----+-----------------------------+\n     # # |   0|{                         |   0|{                            |\n     # # *   1|  array =\u003e [              *   1|  array =\u003e 'JSON_TYPE_INT',  *\n     # # *   2|    'JSON_TYPE_STRING',   *    |                             |\n     # # *   3|    'JSON_TYPE_INT'       *    |                             |\n     # # *   4|  ],                      *    |                             |\n     # # |   5|  int =\u003e 'JSON_TYPE_INT'  |   2|  int =\u003e 'JSON_TYPE_INT'     |\n     # # |   6|}                         |   3|}                            |\n     # # +----+--------------------------+----+-----------------------------+\n     # # Looks like you failed 1 test of 1.\n\nEXAMPLE4\n     use strict;\n     use warnings;\n\n     use Cpanel::JSON::XS::Type;\n     use Test::JSON::Type;\n     use Test::More 'tests' =\u003e 2;\n\n     my $json_struct1 = \u003c\u003c'END';\n     {\n       \"bool\": true,\n       \"float\": 0.23,\n       \"int\": 1,\n       \"null\": null,\n       \"string\": \"bar\"\n     }\n     END\n     my $json_struct2 = \u003c\u003c'END';\n     {\n       \"bool\": false,\n       \"float\": 1.23,\n       \"int\": 2,\n       \"null\": null,\n       \"string\": \"foo\"\n     }\n     END\n     my $expected_type_hr = {\n       'bool' =\u003e JSON_TYPE_BOOL,\n       'float' =\u003e JSON_TYPE_FLOAT,\n       'int' =\u003e JSON_TYPE_INT,\n       'null' =\u003e JSON_TYPE_NULL,\n       'string' =\u003e JSON_TYPE_STRING,\n     };\n     is_json_type($json_struct1, $expected_type_hr, 'Test JSON type #1.');\n     is_json_type($json_struct2, $expected_type_hr, 'Test JSON type #2.');\n\n     # Output:\n     # 1..2\n     # ok 1 - Test JSON type \\#1.\n     # ok 2 - Test JSON type \\#2.\n\nEXAMPLE5\n     use strict;\n     use warnings;\n\n     use Cpanel::JSON::XS::Type;\n     use Test::JSON::Type;\n     use Test::More 'tests' =\u003e 2;\n\n     my $json_struct = \u003c\u003c'END';\n     {\n       \"array\": [1,2,3]\n     }\n     END\n     my $expected_type1_hr = {\n       'array' =\u003e json_type_arrayof(JSON_TYPE_INT),\n     };\n     my $expected_type2_hr = {\n       'array' =\u003e [\n         JSON_TYPE_INT,\n         JSON_TYPE_INT,\n         JSON_TYPE_INT,\n       ],\n     };\n     is_json_type($json_struct, $expected_type1_hr, 'Test JSON type (multiple integers).');\n     is_json_type($json_struct, $expected_type2_hr, 'Test JSON type (three integers)');\n\n     # Output:\n     # 1..2\n     # ok 1 - Test JSON type (multiple integers).\n     # ok 2 - Test JSON type (three integers)\n\nDEPENDENCIES\n    Cpanel::JSON::XS, Cpanel::JSON::XS::Type, English, Error::Pure,\n    Readonly, Test::Builder::Module, Test::Differences.\n\nSEE ALSO\n    Test::JSON\n        Test JSON data\n\n    Test::JSON::More\n        JSON Test Utility\n\n    Test::Deep::JType\n        Test::Deep helpers for JSON::Typist data\n\nREPOSITORY\n    \u003chttps://github.com/michal-josef-spacek/Test-JSON-Type\u003e\n\nAUTHOR\n    Michal Josef Špaček \u003cmailto:skim@cpan.org\u003e\n\n    \u003chttp://skim.cz\u003e\n\nLICENSE AND COPYRIGHT\n    © 2021-2023 Michal Josef Špaček\n\n    BSD 2-Clause License\n\nVERSION\n    0.05\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichal-josef-spacek%2Ftest-json-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichal-josef-spacek%2Ftest-json-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichal-josef-spacek%2Ftest-json-type/lists"}