NAME

Sah::Schemas::JSON - Various schemas related to JSON

VERSION

This document describes version 0.004 of Sah::Schemas::JSON (from Perl distribution Sah-Schemas-JSON), released on 2022-08-25.

SAH SCHEMAS

The following schemas are included in this distribution:

  • any_from_json

    A data structure, coerced from JSON string.

    You can use this schema if you want to accept any data (a data structure or simple scalar), but if user supplies a defined string e.g. in a command-line script as command-line argument or option, the string will be assumed to be a JSON-encoded value and decoded. Data will not be valid if the string does not contain valid JSON.

  • array_from_json

    Array, coercible from JSON string.

    You can use this schema if you want to accept an array, but if user supplies a string e.g. in a command-line script as command-line argument or option, the string will be coerced into array if the string contains a JSON-encoded array. Data will not be valid if the string does not contain valid JSON.

  • hash_from_json

    Hash, coerced from JSON string.

    You can use this schema if you want to accept a hash, but if user supplies a string e.g. in a command-line script as command-line argument or option, the string will be coerced into hash if the string contains a JSON-encoded object (hash). Data will not be valid if the string does not contain valid JSON.

  • json_str

    A string that contains valid JSON.

    This schema can be used if you want to accept a string that contains valid JSON. The JSON string will not be decoded (e.g. a JSON-encoded array will not beome an array) but you know that the string contains a valid JSON. Data will not be valid if the string does not contain valid JSON.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Sah-Schemas-JSON.

SOURCE

Source repository is at https://github.com/perlancar/perl-Sah-Schemas-JSON.

SEE ALSO

Sah - schema specification

Data::Sah - Perl implementation of Sah

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2022, 2021 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-JSON

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.