package Catmandu::Fix::from_json;
use Catmandu::Sane;
use JSON ();
use Moo;
use Catmandu::Fix::Has;
with 'Catmandu::Fix::Base';
has path => (fix_arg => 1);
sub emit {
my ($self, $fixer) = @_;
my $path = $fixer->split_path($self->path);
my $key = pop @$path;
my $json_var = $fixer->capture(JSON->new->utf8(0)->pretty(0)->allow_nonref(1));
$fixer->emit_walk_path($fixer->var,
var} = ${json_var}->decode(${var});" .
"}";
});
});
}
=head1 NAME
Catmandu::Fix::from_json - replace a json field with the parsed value
=head1 SYNOPSIS
from_json(my.fiel
package Catmandu::Exporter::JSON;
use namespace::clean;
use Catmandu::Sane;
use JSON ();
use Moo;
with 'Catmandu::Exporter';
has pretty => (is => 'ro', default => sub { 0 });
has indent
=> (is => 'ro', default => sub { 0 });
has json => (is => 'ro', lazy => 1, builder => '_build_json');
sub _build_json {
my ($self) = @_;
JSON->new
->utf8(0)
->allow_no
my ($self, $data) = @_;
my $fh = $self->fh;
my $json = $self->json->encode($data);
if ($self->pretty) {
chomp $json;
}
if ($self->array) {
if ($self->count) {
package Catmandu::Serializer::json;
use Catmandu::Sane;
use JSON ();
use Moo;
sub serialize {
JSON::encode_json($_[1]);
}
sub deserialize {
JSON::decode_json($_[1]);
}
1;
package Catmandu::Fix::to_json;
use Catmandu::Sane;
use JSON ();
use Moo;
use Catmandu::Fix::Has;
with 'Catmandu::Fix::Base';
has path => (fix_arg => 1);
sub emit {
my ($self, $fixer) = @_;
my $path = $fixer->split_path($self->path);
my $key = pop @$path;
my $json_var = $fixer->capture(JSON->new->utf8(0)->pretty(0)->allow_nonref(1));
$fixer->emit_walk_path($fixer->var, $p
"${var} = ${json_var}->encode(${var});" .
"}";
});
});
}
=head1 NAME
Catmandu::Fix::to_json - convert the value of a field to json
=head1 SYNOPSIS
to_json(my.field)
=
# $Id: JSON.pm 12 2014-06-04 22:14:15Z adam $
package Config::Trivial::JSON;
use base qw( Config::Trivial );
use 5.010;
use strict;
use Carp;
use warnings;
use JSON::MaybeXS;
our $VERSION = '0.0
my $self = shift;
my %args = @_;
my $file = $args{'config_file'}
|| $self->{_json_file}
|| $self->{_config_file};
if ( ( ( $self->{_self} )
&& ( ( $file =
y $json_text = encode_json( $settings );
if ( $json_text ) {
open my $json_file, '>', $file or croak "Unable to store to $file";
print $json_file $json_text;
close $json_fi
tmandu::Importer::JSON;
use namespace::clean;
use Catmandu::Sane;
use JSON ();
use Moo;
with 'Catmandu::Importer';
has json => (is => 'ro', lazy => 1, builder => '_build_json');
has multiline
_json {
my ($self) = @_;
JSON->new->utf8($self->encoding eq ':raw');
}
sub default_encoding { ':raw' }
sub generator {
my ($self) = @_;
$self->multiline ? sub {
state $json
= $self->json;
state $fh = $self->fh;
for (;;) {
my $res = sysread($fh, my $buf, 512);
$res // Catmandu::Error->throw($!);
$json->incr_parse($buf
e Eve::Json;
use parent qw(Eve::Class);
use strict;
use warnings;
use JSON::XS;
use Eve::Exception;
=head1 NAME
B<Eve::Json> - a JSON converter adapter.
=head1 SYNOPSIS
use Eve::Json;
son = Eve::Json->new();
my $json_string = $json->encode(reference => $reference);
my $decoded_reference = $json->decode(string => $json_string);
=head1 DESCRIPTION
The B<Eve::Json> class ad
nality of the JSON::XS
module to provide JSON encoding and decoding features service.
=head1 METHODS
=head2 B<init()>
=cut
sub init {
my $self = shift;
$self->{'json'} = JSON::XS->new()->
er::JSON;
{
$ZMQ::Declare::ZDCF::Encoder::JSON::VERSION = '0.03';
}
use 5.008001;
use Moose;
use parent 'ZMQ::Declare::ZDCF::Encoder';
use JSON ();
my $json = JSON->new;
$json->utf8(1);
$json->pr
$json->encode(shift));
}
sub decode {
my $self = shift;
return $json->decode(${shift()});
}
no Moose;
__PACKAGE__->meta->make_immutable;
__END__
=head1 NAME
ZMQ::Declare::ZDCF::Encoder::JSON
- ZDCF JSON encoder
=head1 SYNOPSIS
use ZMQ::Declare;
=head1 DESCRIPTION
Inherits from
L<ZMQ::Declare::ZDCF::Encoder>.
Implements a JSON encoder/decoder.
=head1 SEE ALSO
The ZDCF RFC L<http:
F::pdf2json;
# ABSTRACT: helper module to retrieve data from pdf2json
$PDF::pdf2json::VERSION = '0.002';
use strict;
use warnings;
use File::Temp;
use Path::Class;
use Alien::pdf2json;
use JSON::Mayb
eXS;
our $alien = Alien::pdf2json->new;
sub pdf2json {
my ($self, $pdf, %param) = @_;
$param{quiet} //= 1;
my $temp_fh = File::Temp->new ( UNLINK => 0 );
my @args = ();
if( exists $param{page}
$alien->pdf2json_path,
'-enc', 'UTF-8',
@args,
$pdf,
$temp_fh->filename,
];
my $ret = system( @$cmd );
die "pdf2json failed" if $ret;
# read data from temp file
my $json_data = file(
package WWW::Jawbone::Up::JSON;
use 5.010;
use strict;
use warnings;
use Carp;
use DateTime;
sub patch {
my ($class, $method, $code) = @_;
no strict 'refs';
*{ $class . '::' . $method } = $c
och(
epoch => $self->{ 'time_' . $method },
time_zone => $self->timezone,
);
});
}
}
sub new {
my ($class, $json) = @_;
return bless $json, $class;
}
1;
Data::Serializer::JSON::XS;
BEGIN { @Data::Serializer::JSON::XS::ISA = qw/Data::Serializer/ }
use warnings;
use strict;
use JSON::XS;
use vars qw/@ISA/;
sub serialize { return JSON::XS->new
->al
cii
->utf8
->relaxed
->pretty( 0 )
->encode( $_[1] );
}
sub deserialize { return JSON::XS->new
->allow_blessed
->allow_nonref
->convert_blessed
->ascii
->utf8
__
=pod
=encoding UTF-8
=head1 NAME
Data::Serializer::JSON::XS
=head1 VERSION
version 0.01
=head1 SYNOPSIS
use Data::Serializer::JSON::XS;
=head1 DESCRIPTION
A serializer using the Data::S
package KiokuDB::TypeMap::Entry::JSON::Scalar;
BEGIN {
$KiokuDB::TypeMap::Entry::JSON::Scalar::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::TypeMap::Entry::JSON::Scalar::VERSION = '0.57';
use Moose;
no w
ke_immutable;
__PACKAGE__
__END__
=pod
=encoding UTF-8
=head1 NAME
KiokuDB::TypeMap::Entry::JSON::Scalar
=head1 VERSION
version 0.57
=head1 AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
=h
KiokuDB::Backend::TypeMap::Default::JSON;
BEGIN {
$KiokuDB::Backend::TypeMap::Default::JSON::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::Backend::TypeMap::Default::JSON::VERSION = '0.57';
use Moose::Role
FIXME options
KiokuDB::TypeMap::Default::JSON->new
}
__PACKAGE__
__END__
=pod
=encoding UTF-8
=head1 NAME
KiokuDB::Backend::TypeMap::Default::JSON
=head1 VERSION
version 0.57
=head1 AUTHO
ackage Cikl::Codecs::JSON;
use strict;
use warnings;
use Cikl::Models::Event;
require JSON::XS;
use Mouse;
use Cikl::Codecs::CodecRole;
use namespace::autoclean;
our $JSON = JSON::XS->new()->utf8(1)
ion/json";
}
sub encode_event {
my $self = shift;
my $event = shift;
return $JSON->encode($event->to_hash());
}
sub decode_event {
my $self = shift;
my $json = shift;
my $data = $JSON->d
ecode($json);
return Cikl::Models::Event->from_hash($data);
}
__PACKAGE__->meta->make_immutable;
1;
package KiokuDB::TypeMap::Default::JSON;
BEGIN {
$KiokuDB::TypeMap::Default::JSON::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::TypeMap::Default::JSON::VERSION = '0.57';
use Moose;
use namespace::clean -
with 'KiokuDB::TypeMap::Default::Canonical' => {
-excludes => [qw(reftype_entries)],
};
has json_boolean_typemap => (
traits => [qw(KiokuDB::TypeMap)],
does => "KiokuDB::Role::
tries,
SCALAR => "KiokuDB::TypeMap::Entry::JSON::Scalar",
REF => "KiokuDB::TypeMap::Entry::JSON::Scalar",
);
}
sub _build_json_boolean_typemap {
my $self = shift;
$sel
package KiokuDB::Serializer::JSON;
BEGIN {
$KiokuDB::Serializer::JSON::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::Serializer::JSON::VERSION = '0.57';
use Moose;
use namespace::clean -except => 'meta';
:Backend::Serialize::JSON
);
sub file_extension { "json" }
__PACKAGE__->meta->make_immutable;
__PACKAGE__
__END__
=pod
=encoding UTF-8
=head1 NAME
KiokuDB::Serializer::JSON
=head1 VERSION
ve
::JSON;
$autobox::JSON::VERSION = '0.0006';
use 5.008;
use strict;
use warnings;
use parent 'autobox';
sub import {
my ($class) = @_;
$class->SUPER::import(
HASH => 'autobox::JSON::
JSON::Ref',
STRING => 'autobox::JSON::String',
);
}
=head1 NAME
autobox::JSON - bringing JSON functions to autobox
=head1 VERSION
version 0.0006
=head1 SYNOPSIS
use autobox::JSON
34}->encode_json;
# {"name":"Jim","age":46}
my $person = '{"name":"Jim","age":46}'->decode_json
# {name => 'Jim', age => 34}
my $serialized_person = $person->encode_json;
# {"na
::JSON;
BEGIN {
$KiokuDB::Backend::Serialize::JSON::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::Backend::Serialize::JSON::VERSION = '0.57';
use Moose::Role;
# ABSTRACT: Role to serialize entries to JSON
t => 1,
);
has json => (
isa => "Object",
is => "rw",
lazy_build => 1,
handles => [qw(encode decode)],
);
sub _build_json {
my $self = shift;
my $json = JSON->new;
for
$json->$flag if $self->$flag;
}
return $json;
}
sub serialize {
my ( $self, @args ) = @_;
$self->encode( $self->collapse_jspon(@args) );
}
sub deserialize {
my ( $self, $json,
ackage Yeb::Plugin::JSON;
BEGIN {
$Yeb::Plugin::JSON::AUTHORITY = 'cpan:GETTY';
}
# ABSTRACT: Yeb Plugin for JSON response
$Yeb::Plugin::JSON::VERSION = '0.101';
use Moo;
use JSON::MaybeXS;
has app
json_attrs_untouched = qw(
ascii latin1 binary pretty indent space_before space_after
relaxed canonical filter_json_object filter_json_single_key_object
shrink max_depth max_size
);
for (@json
y @json_attrs_enabled = qw(
utf8 allow_nonref convert_blessed allow_blessed
);
for (@json_attrs_enabled) {
has $_ => (
is => 'ro',
default => sub { 1 },
);
}
my @json_attrs = ( @json_a
# ABSTRACT: Adds a TO_JSON method to DateTime
package DateTimeX::TO_JSON;
$DateTimeX::TO_JSON::VERSION = '0.0.2';
use strict;
use warnings;
use Class::Load;
use Carp;
sub import {
my ($class, @a
:TO_JSON = sub {
$args{formatter}->format_datetime($_[0]);
}
}
elsif ( $args{formatter} ) {
Class::Load::load_class $args{formatter};
*DateTime::TO_JSON = s
lse {
*DateTime::TO_JSON = sub {
$_[0]->datetime;
}
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
DateTimeX::TO_JSON - Adds a TO_JSON method to DateTime
=head1