NAME
Regexp::Pattern::JSON - Regexp patterns to match JSON
VERSION
This document describes version 0.004 of Regexp::Pattern::JSON (from
Perl distribution Regexp-Pattern-JSON), released on 2018-09-12.
SYNOPSIS
use Regexp::Pattern; # exports re()
my $re = re("JSON::array");
DESCRIPTION
Regexp::Pattern is a convention for organizing reusable regex patterns.
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.
Examples:
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).
Examples:
"{}" =~ 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.
Examples:
"\"\"" =~ 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.
Examples:
"true" =~ re("JSON::value"); # matches
"[]" =~ re("JSON::value"); # matches
"{}" =~ re("JSON::value"); # matches
-1 =~ re("JSON::value"); # matches
"\"\"" =~ re("JSON::value"); # matches
HOMEPAGE
Please visit the project's homepage at
<
https://metacpan.org/release/Regexp-Pattern-JSON>.
SOURCE
Source repository is at
<
https://github.com/perlancar/perl-Regexp-Pattern-JSON>.
BUGS
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.
SEE ALSO
JSON::Decode::Regexp
Regexp::Common::json
AUTHOR
perlancar <
[email protected]>
COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by
[email protected].
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.