Regexp::Pattern::JSON - Regexp patterns to match JSON
This document describes version 0.004 of Regexp::Pattern::JSON (from Perl distribution Regexp-Pattern-JSON), released on 2018-09-12.
use Regexp::Pattern; # exports re() my $re = re("JSON::array");
Regexp::Pattern is a convention for organizing reusable regex patterns.
array
Match a JSON array.
Examples:
"[]" =~ re("JSON::array"); # matches "[1, true, \"abc\"]" =~ re("JSON::array"); # matches # Missing closing bracket "[1" =~ re("JSON::array"); # doesn't match
number
Match a JSON number literal.
12 =~ re("JSON::number"); # matches -34 =~ re("JSON::number"); # matches 1.23 =~ re("JSON::number"); # matches "-1.23e2" =~ re("JSON::number"); # matches
object
Match a JSON object (a.k.a. hash/dictionary).
"{}" =~ re("JSON::object"); # matches "{\"a\":1}" =~ re("JSON::object"); # matches # Missing closing curly bracket "{\"a\":1" =~ re("JSON::object"); # doesn't match # Unquoted key "{a: 1}" =~ re("JSON::object"); # doesn't match
string
Match a JSON string literal.
"\"\"" =~ re("JSON::string"); # matches # Single quotes are not string delimiters "''" =~ re("JSON::string"); # doesn't match "\"\\n\"" =~ re("JSON::string"); # matches "\"contains \\\" double quote\"" =~ re("JSON::string"); # matches
value
Match a JSON value.
"true" =~ re("JSON::value"); # matches "[]" =~ re("JSON::value"); # matches "{}" =~ re("JSON::value"); # matches -1 =~ re("JSON::value"); # matches "\"\"" =~ re("JSON::value"); # matches
Please visit the project's homepage at https://metacpan.org/release/Regexp-Pattern-JSON.
Source repository is at https://github.com/perlancar/perl-Regexp-Pattern-JSON.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Regexp-Pattern-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.
JSON::Decode::Regexp
Regexp::Common::json
perlancar <perlancar@cpan.org>
This software is copyright (c) 2018 by 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.
To install Regexp::Pattern::JSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Regexp::Pattern::JSON
CPAN shell
perl -MCPAN -e shell install Regexp::Pattern::JSON
For more information on module installation, please visit the detailed CPAN module installation guide.