package ThaiSchema::JSON;
use strict;
use warnings;
use utf8;
use ThaiSchema;
use Encode ();
# Licensed under the Artistic 2.0 license.
# See http://www.perlfoundation.org/artistic_license_2_0
.
# This module is based on JSON::Tiny 0.22
my $FALSE = \0;
my $TRUE = \1;
sub ddf {
require Data::Dumper;
local $Data::Dumper::Terse = 1;
Data::Dumper::Dumper(@_);
}
# Escaped specia
# Leading whitespace
m/\G$WHITESPACE_RE/gc;
# Context
my $context = 'Malformed JSON: ' . shift;
if (m/\G\z/gc) { $context .= ' before end of data' }
else {
my @lines
ema
type_int type_str type_number type_hash type_array type_maybe type_bool type_null
/;
use JSON;
use B;
use Data::Dumper;
use Scalar::Util qw/blessed/;
sub match_schema {
local @_ERRORS;
rent qw/ThaiSchema::Base/;
sub is_bool { 1 }
use JSON;
sub match {
my ($self, $value) = @_;
return 0 unless defined $value;
return 1 if JSON::is_bool($value);
return 1 if ref($value) e
tion allows only JSON::true, JSON::false, C<\1>, and C<\0>.
=back
=head1 OPTIONS
=over 4
=item $STRICT
You can check a type more strictly.
This option is useful for checking JSON types.
=item $