tting::VERSION = '0.751';
}
use Any::Moose;
extends 'Prophet::Record';
use Params::Validate;
use JSON;
has default => ( is => 'ro', );
has label => (
isa => 'Str|Undef',
is => 'rw',
);
ha
) ) {
$entry = [@_];
} else {
$entry = shift @_;
}
my $content = to_json(
$entry,
{
canonical => 1,
pretty => 0,
nless $self->load( uuid => $self->uuid );
my $content = $self->get_raw;
my $entry = from_json( $content, { utf8 => 1 } );
return $entry;
}
__PACKAGE__->meta->make_immutable;
no Any::Moos
entAddressedStore;
{
$Prophet::ContentAddressedStore::VERSION = '0.751';
}
use Any::Moose;
use JSON;
use Digest::SHA qw(sha1_hex);
has fs_root => ( is => 'rw', );
has root => (
isa => 'Str',
$content ) = @_;
$content = $$content
if ref($content) eq 'SCALAR';
$content = to_json( $content, { canonical => 1, pretty => 0, utf8 => 1 } )
if ref($content);
my $fingerpri
'0.751';
}
use Any::Moose;
use Prophet::Meta::Types;
use Prophet::ConflictingPropChange;
use JSON 'to_json';
use Digest::SHA 'sha1_hex';
has record_type => (
is => 'rw',
isa => 'Str',
);
h
( delete $_->{source_new_value}, delete $_->{target_value} ) ];
}
return sha1_hex( to_json( $struct, { utf8 => 1, canonical => 1 } ) );
}
__PACKAGE__->meta->make_immutable;
no Any::Moose;
}
use Any::Moose;
extends 'Prophet::Replica';
use File::Spec;
use Params::Validate qw(:all);
use JSON;
use Prophet::Util;
sub replica_exists {
my $self = shift;
return $self->uuid ? 1 : 0;
_no => 1
}
);
require Prophet::ChangeSet;
my $content_struct = from_json( $args{content}, { utf8 => 1 } );
my $changeset = Prophet::ChangeSet->new_from_hashref($conte
S::FS::DirCodec::Universal;
use 5.0080001;
use strict;
use warnings;
use Try::Tiny;
use Carp;
use JSON 2.53 ();
require DataStore::CAS::FS::Dir;
require DataStore::CAS::FS::DirEnt;
require DataStore::
c for saving all arbitrary fields of a DirEnt
our $_json_coder;
sub _build_json_coder {
DataStore::CAS::FS::InvalidUTF8->add_json_filter(
JSON->new->utf8->canonical->convert_blessed, 1
);
}
sub
entry: ".JSON::encode_json($entry);
defined $entry->{type} or croak "Can't serialize typeless directory entry: ".JSON::encode_json($entry);
!defined($_) || (ref $_? ref($_)->can("TO_JSON") : &ut
reference to a hash representation of a change (such as is returned by
L</as_hash> or serialized json) and returns a new Prophet::Change
representation of it.
This method should be invoked as a clas
:CAS::FS::DirCodec::Minimal;
use 5.008001;
use strict;
use warnings;
use Try::Tiny;
use Carp;
use JSON 2.53 ();
require DataStore::CAS::FS::InvalidUTF8;
require DataStore::CAS::FS::Dir;
*decode_utf8=
$entry_list;
my $ret= "CAS_Dir 00 \n";
if ($metadata and scalar keys %$metadata) {
my $enc= JSON->new->utf8->canonical->convert_blessed;
$ret .= $enc->encode($metadata);
}
$ret .= "\0";
$re
ing end of metadata";
if ($meta_end > 0) {
my $enc= JSON->new()->utf8->canonical->convert_blessed;
DataStore::CAS::FS::InvalidUTF8->add_json_filter($enc);
$params->{metadata}= $enc->decode(subs
e Prophet::Web::Result;
use Params::Validate qw/:all/;
use File::Spec ();
use Cwd ();
use JSON;
use HTTP::Date;
# Only define a class type constraint for CGI if it's not already defined,
# be
>cgi->param($_) } $self->cgi->param() } );
$self->_send_redirect( to => "/records/$type/$uuid.json" );
}
sub create_record {
my $self = shift;
my $type = shift;
my $record = $self
aram($_) } $self->cgi->param() } );
return $self->_send_redirect( to => "/records/$type/$uuid.json" );
}
sub get_record_prop {
my $self = shift;
my $type = shift;
my $uuid = shi
end I decided on a
pluggable implementation, where a "Universal" plugin uses something plain like
JSON, and more specialized plugins do things like storing an array of UNIX
'stat' fields. Users can a
em Universal
L<DataStore::CAS::FS::DirCodec::Universal> stores all metadata of each DirEnt
using JSON. If you use this codec, you are guaranteed that anything your
CAS::FS::Scanner picked up was sav
Store::CAS::FS::DirCodec::Unix;
use 5.008;
use strict;
use warnings;
use Try::Tiny;
use Carp;
use JSON 2.53 ();
use Scalar::Util 'looks_like_number';
require DataStore::CAS::FS::Dir;
require DataStore
y encode only the attributes of a UNIX stat()
our $_json_coder;
sub _build_json_coder {
DataStore::CAS::FS::InvalidUTF8->add_json_filter(
JSON->new->utf8->canonical->convert_blessed, 1
);
}
our
{_}{gmap}= \%gmap;
my $meta_json= ($_json_coder ||= _build_json_coder())->encode($metadata);
my $ret= "CAS_Dir 04 unix\n"
.pack('N', length($meta_json)).$meta_json
.join('', sort { substr($a,4
a non-issue.
=head2 Storage Formats
The storage format is supposed to be platform-independent. JSON seems like a
good default encoding, however it requires strings to be in Unicode. When you
encod
ll which were which. This means that
if you take a unicode-as-octets filename and encode it with JSON and decode it
again, perl will mangle it when you attempt to open the file, and fail. It
also me
names
which are not valid UTF-8 are encoded as structures which can be restored
when decoding the JSON.
=head2 Conclusion
In the end, I came up with a module called L<DataStore::CAS::FS::InvalidUTF8
f : $$self.$other);
}
sub add_json_filter {
my ($self, $json)= @_;
$json->filter_json_single_key_object(
'*InvalidUTF8*' => \&FROM_JSON
);
$json;
}
sub TO_JSON {
my $x= ${$_[0]};
utf8::upgr
ade($x);
return { '*InvalidUTF8*' => $x };
}
sub FROM_JSON {
my $x= $_[0];
utf8::downgrade($x) if utf8::is_utf8($x);
return bless \$x, __PACKAGE__;
}
sub TO_UTF8 {
${$_[0]};
}
1;
__END__
=po
SYNOPSIS
my $j= JSON->new()->convert_blessed;
DataStore::CAS::FS::InvalidUTF8->add_json_filter($j);
my $x= DataStore::CAS::FS::InvalidUTF8->decode_utf8("\x{FF}");
my $json= $j->encode($x);
FATAL => 'all';
use Moo;
use Getopt::Long qw(GetOptionsFromArray);
use Redis;
use Try::Tiny;
use JSON;
=head1 NAME
Uninets::Check::Modules::Redis - Uninets::Check module to check redis servers.
=h
my ($self, $status, $value, $format) = @_;
return JSON->new->encode(
{
message => $value,
status => $status,
}
) if $format eq 'json';
# default last in case some non supported format
'Default: num',
},
formats => {
'num' => 'Returns the status code',
'json' => 'Returns a JSON structure',
},
},
size => {
description => 'Check redis RAM consumption',
package NG;
use strict;
use warnings;
use Try::Tiny;
use autodie;
use YAML::XS ();
use JSON::XS ();
use XML::Simple;
use Spreadsheet::ParseExcel;
use NG::Autobox;
use NG::Array;
use NG::DB;
use NG::Ex
RT = qw(
local_run
remote_run
fork_run
taskset
web_get
mail_send
mail_get
from_json
from_yaml
mkdir_p
rm_r
cp_r
read_file
read_dir
file_stat
process_log
geo_ip
Hashtable->new($ref)
: NG::Array->new($ref);
}
sub from_json {
my $data = &read_file(@_);
my $ref = JSON::XS::decode_json($data);
return ref($ref) eq 'HASH'
? NG::Hashtable->
st;
use Plack::Util::Accessor qw(route method path receipt_data allow_sandbox shared_secret);
use JSON;
use Try::Tiny;
use Furl;
sub prepare_app {
my $self = shift;
$self->allow_sandbox( $se
$params{password} = $self->shared_secret if $self->shared_secret;
my $receipt_data = encode_json (\%params);
my $res;
$res = $self->_post_receipt_to_itunes( 'production', $receipt_data,
> 'application/json'], # headers
$receipt_data, # form data (HashRef/FileHandle are also okay)
);
return [200, ['Content-Type' => 'application/json'], [$res->cont
=item *
L<autobox|autobox>
=item *
L<autobox::Core|autobox::Core>
=item *
L<autobox::JSON|autobox::JSON>
=item *
L<MIME::Base64|MIME::Base64>
=back
=head1 SOURCE
The development version is
tmp/file');
say $f->fstat;
=head1 METHODS
=head2 from_json/yaml
Return Hashtable or Array:
my $object = NG::File->from_yaml/json($file);
=head2 read_file
my $filepath = '/home/chenry
eplica';
use Params::Validate qw(:all);
use File::Spec ();
use File::Path;
use Prophet::Util;
use JSON;
use Digest::SHA qw/sha1_hex/;
use DBI;
has dbh => (
is => 'rw',
isa => 'DBI::d
;
my $cs = $self->_load_changeset_from_db( sha1 => $args{sha1} );
return $cs->canonical_json_representation;
}
sub _load_changeset_from_db {
my $self = shift;
my %args = validate(
'all';
use Moo;
use Getopt::Long qw(GetOptionsFromArray);
use Mojo::UserAgent;
use Try::Tiny;
use JSON;
use Time::HiRes;
=head1 NAME
Uninets::Check::Modules::HTTP - Uninets::Check module to check we
, $value, $format) = @_;
return JSON->new->encode(
{
message => $value,
status => $status,
}
) if $format eq 'json';
# default last in case some n
mats => {
'num' => 'Returns the status code',
'json' => 'Returns a JSON structure',
},
default_format => 'num',
},
olutionDB::VERSION = '0.751';
}
use Any::Moose;
use Prophet::Change;
use Prophet::Collection;
use JSON;
use Digest::SHA 'sha1_hex';
extends 'Prophet::Resolver';
sub run {
my $self =
y %answer_count;
for my $answer ( $res->items ) {
my $key = sha1_hex(
to_json(
$answer->get_props, { utf8 => 1, pretty => 1, canonical => 1 }
)