Group
Extension

Matches 35359

Yars ( B/BD/BDUGGAN/Yars-0.77.tar.gz, BDUGGAN, 2012; MetaCPAN )
Yars/lib/Yars/Tools.pm ( view source; MetaCPAN )
se Data::Dumper;
use Try::Tiny;
use File::Path qw/mkpath/;
use File::Temp;
use File::Compare;
use JSON::XS;
use File::stat qw/stat/;
use Mojo::ByteStream qw/b/;
use strict;
use warnings;

our %Bucket2
tateFile;
    return $cached if $mod_time && $mod_time == stat($StateFile)->mtime;
    our $j ||= JSON::XS->new;
    -e $StateFile or LOGDIE "Missing state file $StateFile";
    $cached = $j->decode(M
{
    my $class = shift;
    my $state = shift;
    my $dir = dirname($StateFile);
    our $j ||= JSON::XS->new;
    mkpath $dir;
    my $temp = File::Temp->new(DIR => $dir, UNLINK => 0);
    print $t
Catalyst-Runtime ( B/BO/BOBTFISH/Catalyst-Runtime-5.90019.tar.gz, JJNAPIORK, 2012; MetaCPAN )
Catalyst-Runtime/lib/Catalyst/ActionRole/ConsumesContent.pm ( view source; MetaCPAN )
=>'HashRef',
  builder=>'_build_normalized');


sub _build_normalized {
  return +{
    JSON => 'application/json',
    JS => 'application/javascript',
    PERL => 'application/perl',
    HTML => 'tex


    sub start : POST Chained('/') CaptureArg(0) { ... }

      sub is_json       : Chained('start') Consumes('application/json') { ... }
      sub is_urlencoded : Chained('start') Consumes('applicat
form-data') { ... }

      ## Alternatively, for common types...

      sub is_json       : Chained('start') Consume(JSON) { ... }
      sub is_urlencoded : Chained('start') Consumes(UrlEncoded) { ...
WWW-Foursquare ( F/FX/FXZUZ/WWW-Foursquare-0.9906.tar.gz, FXZUZ, 2012; MetaCPAN )
WWW-Foursquare/lib/WWW/Foursquare.pm ( view source; MetaCPAN )
;
use WWW::Foursquare::Events;
use WWW::Foursquare::Pages;
use WWW::Foursquare::Pageupdates;

use JSON;
use LWP;
use URI::Escape;

sub new {
    my ($class, %params) = @_;
    
    my $self = {};
    
l" if $self->{debug};

    my $res = $self->{request}->{ua}->get($result_url);

    return decode_json($res->content()) if $res->code() == 200;

    # throw exception
    die $res->content();
}

sub _
WWW-Foursquare ( F/FX/FXZUZ/WWW-Foursquare-0.9906.tar.gz, FXZUZ, 2012; MetaCPAN )
WWW-Foursquare/lib/WWW/Foursquare/Response.pm ( view source; MetaCPAN )
package WWW::Foursquare::Response;

use strict;
use warnings;

use JSON;

our %ERROR_TYPE = (
    invalid_auth        => 'OAuth token was not provided or was invalid',
    param_error         => 'A re
elf, $class;
    return $self;
}

sub process {
    my ($self, $res) = @_;

    my $data = decode_json($res->content());
    my $code = $res->code();

    # response is OK
    return $data->{response}
MooseX-Storage ( B/BO/BOBTFISH/MooseX-Storage-0.32.tar.gz, BOBTFISH, 2012; MetaCPAN )
MooseX-Storage/lib/MooseX/Storage.pm ( view source; MetaCPAN )
Point;
  use Moose;
  use MooseX::Storage;

  our $VERSION = '0.01';

  with Storage('format' => 'JSON', 'io' => 'File');

  has 'x' => (is => 'rw', isa => 'Int');
  has 'y' => (is => 'rw', isa => 'In
zation format
  ## (in this case JSON)

  # pack the class into a JSON string
  $p->freeze(); # { "__CLASS__" : "Point-0.01", "x" : 10, "y" : 10 }

  # unpack the JSON string into a class
  my $p2 = P
methods to load/store a class
  ## on the file system

  $p->store('my_point.json');

  my $p2 = Point->load('my_point.json');

=head1 DESCRIPTION

MooseX::Storage is a serialization framework for Moo
MooseX-Attribute-Deflator ( P/PE/PERLER/MooseX-Attribute-Deflator-2.2.2.tar.gz, PERLER, 2012; MetaCPAN )
MooseX-Attribute-Deflator/lib/MooseX/Attribute/Deflator/Moose.pm ( view source; MetaCPAN )
eX::Attribute::Deflator;
use JSON;

if($ENV{HARNESS_ACTIVE}) {
    deflate [qw(ArrayRef HashRef)], via { JSON->new->utf8->canonical->encode($_) },
        inline_as {'JSON->new->utf8->canonical->encod
ef)], via { JSON->new->utf8->canonical->decode($_) },
        inline_as {'JSON->new->utf8->canonical->decode($value)'};
} else {
    deflate [qw(ArrayRef HashRef)], via { JSON::encode_json($_) },
    
    inline_as {'JSON::encode_json($value)'};
    inflate [qw(ArrayRef HashRef)], via { JSON::decode_json($_) },
        inline_as {'JSON::decode_json($value)'};
}


deflate 'ScalarRef', via {$$_}, inl
Catalyst-Runtime ( B/BO/BOBTFISH/Catalyst-Runtime-5.90019.tar.gz, JJNAPIORK, 2012; MetaCPAN )
Catalyst-Runtime/lib/Catalyst/UTF8.pod ( view source; MetaCPAN )
tempt to encode C<application/json> since the two most commonly used
approaches (L<Catalyst::View::JSON> and L<Catalyst::Action::REST>) have already configured
their JSON encoders to produce properly 
nses.  If you are rolling your
own JSON encoding, you may need to set the encoder to do the right thing (or override
the global regular expression to include the JSON media type).

=head2 Encoding wit
MooseX-Attribute-Deflator ( P/PE/PERLER/MooseX-Attribute-Deflator-2.2.2.tar.gz, PERLER, 2012; MetaCPAN )
MooseX-Attribute-Deflator/lib/MooseX/Attribute/Deflator.pm ( view source; MetaCPAN )
 Loading L<MooseX::Attribute::Deflator::Moose>
will cause HashRefs and ArrayRefs to be encoded as JSON strings. However, you can simply overwrite
those deflators (and inflators) to deflate to somethin
C<benchmark.pl> tests three ways of deflating the value of a HashRef attribute
to a json encoded string (using L<JSON>).

 my $obj     = MyBenchmark->new( hashref => { foo => 'bar' } );
 my $attr    =
ate($obj); 

Using the deflate attribute method, supplied by this module.

=item accessor

 JSON::encode_json($obj->hashref);

If the attribute comes with an accessor, you can use this
method, to defl
Morpheus ( D/DR/DRUXA/Morpheus-0.46.tar.gz, DRUXA, 2012; MetaCPAN )
Morpheus/debuild/source/t/script.t ( view source; MetaCPAN )
,
    'morph without arguments prints json'
);

$result = qx(bin/morph /foo/bar);
like(
    $result,
    qr/^(5|"5")\n$/,
    'morph without arguments prints json'
);

$result = qx(bin/morph --format=
Kossy ( K/KA/KAZEBURO/Kossy-0.13.tar.gz, KAZEBURO, 2012; MetaCPAN )
Kossy/lib/Kossy/Request.pm ( view source; MetaCPAN )
er::MultiPart'
);

my $json_parser = HTTP::Entity::Parser->new();
$json_parser->register(
    'application/x-www-form-urlencoded',
    'HTTP::Entity::Parser::UrlEncoded'
);
$json_parser->register(
   
t'
);
$json_parser->register(
    'application/json',
    'HTTP::Entity::Parser::JSON'
);

my $json_only_parser = HTTP::Entity::Parser->new();
$json_only_parser->register(
    'application/json',
    
'HTTP::Entity::Parser::JSON'
);

sub _build_request_body_parser {
    my $self = shift;
    if ( $self->env->{'kossy.request.parse_json_body'} ) {
        return $json_parser;
    }
    $default_parse
JavaScript-Console ( A/AK/AKZHAN/JavaScript-Console-0.01.tar.gz, AKZHAN, 2012; MetaCPAN )
JavaScript-Console/lib/JavaScript/Console.pm ( view source; MetaCPAN )
e JSON::XS ();

use constant DEFAULT_CHARSET => 'utf-8';

my $json = undef;

sub _default_formatter {
    my $value = shift;
    $json ||= JSON::XS->new->allow_nonref->allow_blessed;
    return $json-
value ), returns JavaScript representation for the value.
                                        JSON::XS-based by default.

    * charset   - Charset, utf-8 by default.

=cut

sub new {
    my ( $cl
MooseX-Storage ( B/BO/BOBTFISH/MooseX-Storage-0.32.tar.gz, BOBTFISH, 2012; MetaCPAN )
MooseX-Storage/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm ( view source; MetaCPAN )
ad1 SYNOPSIS

  package Point;
  use Moose;
  use MooseX::Storage;
  
  with Storage('format' => 'JSON', 'io' => 'File');
  
  has 'x' => (is => 'rw', isa => 'Int');
  has 'y' => (is => 'rw', isa => '
MooseX-Storage ( B/BO/BOBTFISH/MooseX-Storage-0.32.tar.gz, BOBTFISH, 2012; MetaCPAN )
MooseX-Storage/lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm ( view source; MetaCPAN )
ad1 SYNOPSIS

  package Point;
  use Moose;
  use MooseX::Storage;
  
  with Storage('format' => 'JSON', 'io' => 'File');
  
  has 'x' => (is => 'rw', isa => 'Int');
  has 'y' => (is => 'rw', isa => '
MooseX-Storage ( B/BO/BOBTFISH/MooseX-Storage-0.32.tar.gz, BOBTFISH, 2012; MetaCPAN )
MooseX-Storage/lib/MooseX/Storage/Format/YAML.pm ( view source; MetaCPAN )
 YAML string
  $p->freeze();

  # ----
  # __CLASS__: "Point"
  # x: 10
  # y: 10

  # unpack the JSON string into a class
  my $p2 = Point->thaw(<<YAML);
  ----
  __CLASS__: "Point"
  x: 10
  y: 10
 
App-Presto ( B/BP/BPHILLIPS/App-Presto-0.009.tar.gz, BPHILLIPS, 2012; MetaCPAN )
App-Presto/lib/App/Presto/PrettyPrinter.pm ( view source; MetaCPAN )
::Dumper::Sortkeys = 1;
        return Data::Dumper::Dumper(shift);
    },
    'JSON' => sub { require JSON; return JSON->new->pretty->encode(shift) },
    'YAML' => sub { require YAML; return YAML::D
MooseX-Storage ( B/BO/BOBTFISH/MooseX-Storage-0.32.tar.gz, BOBTFISH, 2012; MetaCPAN )
MooseX-Storage/lib/MooseX/Storage/Util.pm ( view source; MetaCPAN )
e_json {
    my ($class, $json) = @_;

    eval { require JSON::Any; JSON::Any->import };
    confess "Could not load JSON module because : $@" if $@;

    utf8::encode($json) if utf8::is_utf8($json);


    my $data = eval { JSON::Any->jsonToObj($json) };
    if ($@) {
        confess "There was an error when attempting to peek at JSON: $@";
    }

    return $data;
}

sub _inflate_yaml {
    my ($

unfreeze/unpack it.

The C<$data> can be either a perl HASH ref or some kind of serialized
data (JSON, YAML, etc.).

The C<%options> are as follows:

=over 4

=item I<format>

If this is left blank, 
MooseX-Storage ( B/BO/BOBTFISH/MooseX-Storage-0.32.tar.gz, BOBTFISH, 2012; MetaCPAN )
MooseX-Storage/lib/MooseX/Storage/IO/AtomicFile.pm ( view source; MetaCPAN )
head1 SYNOPSIS

  package Point;
  use Moose;
  use MooseX::Storage;

  with Storage('format' => 'JSON', 'io' => 'AtomicFile');

  has 'x' => (is => 'rw', isa => 'Int');
  has 'y' => (is => 'rw', isa 
methods to load/store a class
  ## on the file system

  $p->store('my_point.json');

  my $p2 = Point->load('my_point.json');

=head1 METHODS

=over 4

=item B<load ($filename)>

=item B<store ($file
MooseX-Storage ( B/BO/BOBTFISH/MooseX-Storage-0.32.tar.gz, BOBTFISH, 2012; MetaCPAN )
MooseX-Storage/lib/MooseX/Storage/IO/File.pm ( view source; MetaCPAN )
head1 SYNOPSIS

  package Point;
  use Moose;
  use MooseX::Storage;

  with Storage('format' => 'JSON', 'io' => 'File');

  has 'x' => (is => 'rw', isa => 'Int');
  has 'y' => (is => 'rw', isa => 'In
methods to load/store a class
  ## on the file system

  $p->store('my_point.json');

  my $p2 = Point->load('my_point.json');

=head1 METHODS

=over 4

=item B<load ($filename)>

=item B<store ($file
Kossy ( K/KA/KAZEBURO/Kossy-0.13.tar.gz, KAZEBURO, 2012; MetaCPAN )
Kossy/lib/Kossy/Connection.pm ( view source; MetaCPAN )
 (
    new => 1,
    rw => [qw/req res stash args tx debug json_serializer/]
);
use Kossy::Exception;

our $VERSION = '0.63';

# for IE7 JSON venularity.
# see http://www.atmarkit.co.jp/fcoding/articl
es/webapp/05/webapp05a.html
# Copy from Amon2::Plugin::Web::JSON => Fixed to escape only string parts
my %_ESCAPE = (
    '+' => '\\u002b', # do not eval as UTF-7
    '<' => '\\u003c', # do not eval a
   my $body = shift;
    $body =~ s!([+<>])!$_ESCAPE{$1}!g;
    return qq("$body");
}

sub escape_json {
    my $self = shift;
    my $body = shift;
    # escape only string parts
    $body =~ s/"((?:
App-Presto ( B/BP/BPHILLIPS/App-Presto-0.009.tar.gz, BPHILLIPS, 2012; MetaCPAN )
App-Presto/lib/App/Presto/Config.pm ( view source; MetaCPAN )
ON = '0.009';
}

# ABSTRACT: Manage configuration for a given endpoint

use Moo;
use JSON qw(decode_json encode_json);
use File::HomeDir;
use File::Path 2.08 qw(make_path);

has endpoint => (
    is =
'HASH'; },
);
sub _build_config {
    my $self = shift;
    my $config_file = $self->file('config.json');
    if (! -e $config_file ) {
        warn "creating new config file: $config_file\n";
       
ode_json({});
        close $fh;
    }

    my $config;
    eval {
        local $/;
        open( my $fh, '<', $config_file ) or die "Unable to open $config_file for reading: $!";
        my $json_te

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.