n 'integer';
}
method type_integer_unsigned(HashRef $data) {
return 'integer';
}
method type_json(HashRef $data) {
return 'text';
}
method type_number(HashRef $data) {
return $self->type_i
te;
=cut
=head1 DESCRIPTION
This package provides methods for converting
L<json-sql|https://github.com/iamalnewkirk/json-sql> data structures into
SQLite statements.
=cut
=head1 INHERITS
This pa
_json
type_json(HashRef $data) : Str
The type_json method returns the SQL expression representing a json data type.
=over 4
=item type_json example #1
# given: synopsis
$grammar->type_json
') {
return $self->type_integer_unsigned($data);
}
if ($data->{type} eq 'json') {
return $self->type_json($data);
}
if ($data->{type} eq 'number') {
return $self->type_number($da
n 'integer';
}
method type_integer_unsigned(HashRef $data) {
return 'integer';
}
method type_json(HashRef $data) {
return 'text';
}
method type_number(HashRef $data) {
return 'integer';
}
te;
=cut
=head1 DESCRIPTION
This package provides methods for converting
L<json-sql|https://github.com/iamalnewkirk/json-sql> data structures into
SQL statements.
=cut
=head1 LIBRARIES
This pack
ata) {
return join ' ', $self->type_integer($data), 'unsigned';
}
method type_json(HashRef $data) {
return 'json';
}
method type_number(HashRef $data) {
return $self->type_integer($data);
}
te;
=cut
=head1 DESCRIPTION
This package provides methods for converting
L<json-sql|https://github.com/iamalnewkirk/json-sql> data structures into
MySQL statements.
=cut
=head1 INHERITS
This pac
_json
type_json(HashRef $data) : Str
The type_json method returns the SQL expression representing a json data type.
=over 4
=item type_json example #1
# given: synopsis
$grammar->type_json
er;
use Errno qw(:POSIX);
use HTTP::Request;
use HTTP::Status qw(:constants);
use JSON;
use LWP::UserAgent;
use Throw qw(throw classify);
use Try::Tiny qw(try catch);
}
);
} else {
my $content = decode_json($response->content);
my $uri = $response->base->as_string;
tem doesn't exist, it throws an exception (error code 6).
Unlike C<stat>, it only returns in the JSON response the node name, type, and
whether it has any children. In addition, while C<stat> only re
ethod type_integer_unsigned(HashRef $data) {
return $self->type_integer($data);
}
method type_json(HashRef $data) {
return 'nvarchar(max)';
}
method type_number(HashRef $data) {
return $sel
te;
=cut
=head1 DESCRIPTION
This package provides methods for converting
L<json-sql|https://github.com/iamalnewkirk/json-sql> data structures into
MSSQL statements.
=cut
=head1 INHERITS
This pac
_json
type_json(HashRef $data) : Str
The type_json method returns the SQL expression representing a json data type.
=over 4
=item type_json example #1
# given: synopsis
$grammar->type_json
}
#pod =method TO_JSON
#pod
#pod Returns the value as a string.
#pod
#pod If the C<BSON_EXTJSON> option is true, it will instead
#pod be compatible with MongoDB's L<extended JSON|https://github.com/
aster/source/extended-json.rst>
#pod format, which represents it as a document as follows:
#pod
#pod {"$numberDecimal" : "2.23372036854775807E+57"}
#pod
#pod =cut
sub TO_JSON {
return "" . $_
[0]->value unless $ENV{BSON_EXTJSON};
return { '$numberDecimal' => "" . ($_[0]->value) };
}
use overload (
q{""} => sub { $_[0]->value },
fallback => 1,
);
1;
=pod
=encoding UTF-8
er;
use Errno qw(:POSIX);
use HTTP::Request;
use HTTP::Status qw(:constants);
use JSON;
use LWP::UserAgent;
use Throw qw(throw classify);
use Try::Tiny qw(try catch);
tem doesn't exist, it throws an exception (error code 6).
Unlike C<stat>, it only returns in the JSON response the node name, type, and
whether it has any children. In addition, while C<stat> only re
e Data::Object::Class;
use Data::Object::ClassHas;
use JSON::Validator;
our $VERSION = '0.02'; # VERSION
our $GITHUB_SOURCE = 'iamalnewkirk/json-sql';
# ATTRIBUTES
has schema => (
is => 'ro',
=> 'InstanceOf["JSON::Validator"]',
new => 1
);
fun new_validator($self) {
local $ENV{JSON_VALIDATOR_CACHE_ANYWAYS} = 1
unless exists $ENV{JSON_VALIDATOR_CACHE_ANYWAYS};
JSON::Validator->ne
issues ? 1 : 0;
}
1;
=encoding utf8
=head1 NAME
SQL::Validator - Validate JSON-SQL
=cut
=head1 ABSTRACT
Validate JSON-SQL Schemas
=cut
=head1 SYNOPSIS
use SQL::Validator;
my $sql = SQL::
mon JSON boolean classes
Most JSON libraries on CPAN implement their own boolean classes. The
following libraries boolean types will now encode correctly as BSON
booleans:
=over 4
=item *
JSON::X
S
=item *
Cpanel::JSON::XS
=item *
JSON::PP
=item *
JSON::Tiny
=item *
Mojo::JSON
=back
=head2 DBRef objects
The C<fetch> method and related attributes C<client>, C<verify_db>, and
C<verify
L';
Your metadata ( META.yml or META.json ) will have an entry looking like this:
x_authority => 'cpan:APOCAL'
=for stopwords RJBS metadata FLORA dist ini json username yml
=for Pod::Coverage met
lowing JSON libraries will also be encoded
correctly in the database:
=over 4
=item *
L<JSON::XS>
=item *
L<JSON::PP>
=item *
L<Cpanel::JSON::XS>
=item *
L<Mojo::JSON>
=item *
L<JSON::Tiny>
od TO_JSON
#pod
#pod On a 64-bit perl, returns the value as an integer. On a 32-bit Perl, it
#pod will be returned as a Math::BigInt object, which will
#pod fail to serialize unless a C<TO_JSON> meth
the C<BSON_EXTJSON> environment variable is true and the
#pod C<BSON_EXTJSON_RELAXED> environment variable is false, returns a hashref
#pod compatible with
#pod MongoDB's L<extended JSON|https://githu
ob/master/source/extended-json.rst>
#pod format, which represents it as a document as follows:
#pod
#pod {"$numberLong" : "223372036854775807"}
#pod
#pod =cut
sub TO_JSON {
return int($_[0]->
TO_JSON
#pod
#pod Returns Base64 encoded string equivalent to the data attribute.
#pod
#pod If the C<BSON_EXTJSON> option is true, it will instead be compatible with
#pod MongoDB's L<extended JSON|ht
ce/extended-json.rst>
#pod format, which represents it as a document as follows:
#pod
#pod {"$binary" : { "base64": "<base64 data>", "subType" : "<type>"} }
#pod
#pod =cut
sub TO_JSON {
retur
n MIME::Base64::encode_base64($_[0]->{data}, "") unless $ENV{BSON_EXTJSON};
my %data;
tie( %data, 'Tie::IxHash' );
$data{base64} = MIME::Base64::encode_base64($_[0]->{data}, "");
$dat
TO_JSON
#pod
#pod If the C<BSON_EXTJSON> option is true, returns a hashref compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rs
pod If the C<BSON_EXTJSON> option is false, an error is thrown, as this value
#pod can't otherwise be represented in JSON.
#pod
#pod =cut
sub TO_JSON {
if ( $ENV{BSON_EXTJSON} ) {
return
{ '$minKey' => 1 };
}
croak( "The value '$_[0]' is illegal in JSON" );
}
1;
=pod
=encoding UTF-8
=head1 NAME
BSON::MinKey - BSON type wrapper for MinKey
=head1 VERSION
version v1.12.2
er_unsigned(HashRef $data) {
return $self->type_integer($data);
}
method type_json(HashRef $data) {
return 'json';
}
method type_number(HashRef $data) {
return $self->type_integer($data);
}
te;
=cut
=head1 DESCRIPTION
This package provides methods for converting
L<json-sql|https://github.com/iamalnewkirk/json-sql> data structures into
PostgreSQL statements.
=cut
=head1 INHERITS
Thi
_json
type_json(HashRef $data) : Str
The type_json method returns the SQL expression representing a json data type.
=over 4
=item type_json example #1
# given: synopsis
$grammar->type_json
= '0.02'; # VERSION
# ATTRIBUTES
has 'issues' => (
is => 'ro',
isa => 'ArrayRef[InstanceOf["JSON::Validator::Error"]]',
req => 1,
);
# METHODS
method match(Str $key = '/') {
$key =~ s/^\/*
SQL::Validator::Error - JSON-SQL Schema Validation Error
=cut
=head1 ABSTRACT
JSON-SQL Schema Validation Error
=cut
=head1 SYNOPSIS
use SQL::Validator::Error;
use JSON::Validator::Error;
dator::Error->new(
issues => [
JSON::Validator::Error->new('/root', 'not okay'),
JSON::Validator::Error->new('/node/0', 'not okay'),
JSON::Validator::Error->new('/node/1', 'not o
* JSON::PP::Boolean so it is listed at the end for compatibility
* with old versions of it. Old versions of Cpanel::JSON::XS
* similarly have their own type, but now use JSON::PP::
strEQ(obj_type, "JSON::XS::Boolean") ||
strEQ(obj_type, "JSON::PP::Boolean") ||
strEQ(obj_type, "JSON::Tiny::_Bool") ||
strEQ(obj_type, "Mojo::JSON::_Bool") ||
strEQ(obj_type, "Cpanel::JSON::XS::Boolean") ||
strEQ(obj_type, "Types::Serialiser::Boolean")
) {
bson_append_bool(bson, key, -1, SvIV(SvRV(sv)));
}
else if (s
bool allow_null);
char *bson_utf8_escape_for_json (const char *utf8,
ssize_t utf8_len);
bson
===================
#
# FILE: rest-client.pl
#
# USAGE: ./rest-client.pl -config <JSON-encoded config string>
#
# DESCRIPTION:
# performs request and display (eventually decoded) r
;
use JSON qw( from_json to_json decode_json );
use Data::Dumper qw( Dumper );
use LWP::ConsoleLogger::Everywhere ();
use RestAPI ();
$Data::Dumper::Indent = 1;
my $config_as_json;
my
$0
-config # a JSON-encoded configuration snippet, or
-config_file # a JSON-encoded file
EOT
}
GetOptions(
"config=s" => \$config_as_json,
"config_file=s" => \$con
value} / 1.0 : 0.0;
}
#pod =method TO_JSON
#pod
#pod Returns a double.
#pod
#pod If the C<BSON_EXTJSON> environment variable is true and the
#pod C<BSON_EXTJSON_RELAXED> environment variable is false
rns a hashref
#pod compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rst>
#pod format, which represents it as a document as foll
{"$numberDouble" : "42.0"}
#pod
#pod If C<BSON_EXTJSON> is false and the value is 'Inf', '-Inf' or 'NaN'
#pod (which are illegal in regular JSON), then an exception is thrown.
#pod
#pod =cut
my $u