package OpenGuides::JSON;
use strict;
use vars qw( $VERSION );
$VERSION = '0.03';
use Wiki::Toolkit::Plugin::JSON;
use Time::Piece;
use URI::Escape;
use Carp 'croak';
use JSON;
use OpenGuides::CGI;
rsion} = $args{og_version};
$self;
}
=over 4
=item B<emit_json>
Renders the given node as JSON
=cut
sub emit_json {
my ( $self, %args ) = @_;
my $node_name = $args{node};
f->json_maker->make_json($data);
}
=item B<output_as_json>
Renders the given arbitary data as JSON
=cut
sub output_as_json {
my ( $self, %args ) = @_;
return $self->json_maker->make_json(\
ilter::JSON;
use 5.006;
use strict;
use warnings 'all';
use Carp;
use Data::Printer::Filter qw/filter p/;
use Term::ANSIColor;
our $VERSION = '0.3';
=head1 NAME
Data::Printer::Filter::JSON - pret
ty-print your decoded JSON structures!
=head1 VERSION
Version 0.03
=head1 SYNOPSIS
# In your program:
use Data::Printer filters => {
-external => [ 'JSON' ],
};
# or, in your C<.
l => [ 'JSON' ],
},
};
# You can also tweak the colors:
use Data::Printer {
filters => {
-external => [ 'JSON' ],
}, color => {
JSON => {
package eBay::API::Simple::JSON;
use strict;
use warnings;
use base 'eBay::API::SimpleBase';
use JSON;
use HTTP::Request;
use HTTP::Headers;
use XML::Simple;
use URI::Escape;
use utf8;
our $DEBUG =
0;
=head1 NAME
eBay::API::Simple::JSON - Support for grabbing an RSS feed via API call
=head1 USAGE
my $api = eBay::API::Simple::JSON->new();
my $data = {
"user_eais_token" => "tim
$endpoint );
=head1 PUBLIC METHODS
=head2 new( { %options } }
my $call = ebay::API::Simple::JSON->new();
=cut
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$sel
package Inline::JSON;
use v5.10;
use strict;
use warnings;
no warnings 'once';
use Filter::Simple;
use JSON;
# This is using recursive balanced regex as per:
# http://learn.perl.org/faq/perlfaq6.h
{
s/
( # Outer capture group 1 start
json: (\s*) # Capture group 2 (space) start
( # Capture
)
/
my $space = $2;
my $json = $3;
$json =~ s|'|\\'|;
$space."JSON->new->decode('$json')";
/gsex;
},
'executable' => sub {
package Ambrosia::View::JSON;
use strict;
use warnings;
use Carp;
use JSON::XS ();
use Ambrosia::Meta;
class sealed
{
extends => [qw/Ambrosia::View/],
};
our $VERSION = 0.010;
sub process
{
return $self->as_json;
}
sub as_json
{
my $self = shift;
my $json = JSON::XS->new;
$json->utf8(0);
$json->latin1(1);
my $str = '';
eval
{
$json->convert_blessed
elf->data ? $json->encode($self->data) : '{}';
warn "$str\n";
};
if ( $@ )
{
carp "ERROR: $@";
}
return $str;
}
1;
__END__
=head1 NAME
Ambrosia::View::JSON - it is VIE
package MARC::File::JSON;
# ABSTRACT: read/write MARC data into JSON format
use strict;
use warnings;
use JSON;
use JSON::Streaming::Reader;
use MARC::Record::Generic;
use MARC::Record;
use MARC::Fi
push @ISA, 'MARC::File';
# MARC::Record -> JSON
sub encode {
my $record = shift;
return JSON->new->utf8->encode( $record->as_generic );
}
# JSON -> MARC::Record
sub decode {
my ($self,
$data = JSON->new->utf8->decode( $data );
}
return MARC::Record->new_from_generic( $data );
}
sub _next {
my $self = shift;
my $jsonr
= $self->{jsonr} //= JSON::Streaming:
ocal $Text::Wrap::huge = 'overflow';
our %outputformats = (
anvl => 'ANVL',
csv => 'CSV',
json => 'JSON',
plain => 'Plain',
psv => 'PSV',
turtle => 'Turtle',
xml => 'XML',
);
sub listformats
rall starting indent
indent_step => # how much to increment/decrement indent
' ', # for XML, JSON
outhandle => '', # return string by default
turtle_indent => # turtle has one indent width
'
/"/; # trim both ends and double-quote
return $s;
}
package File::OM::JSON;
our @ISA = ('File::OM');
sub elem { # OM::JSON
my $self = shift;
my ($name, $value, $lineno, $elemnum) = (shift, shif
in::Dump::Format::json;
use Moose::Role;
use JSON;
sub format {
my ($self, %params) = @_;
my $data = $self->_convert_to_array_of_hashes($params{table_data});
return JSON->new->encode($da
package Data::Properties::JSON;
use strict;
use warnings 'all';
use JSON::XS;
our $VERSION = '0.004';
sub new
{
my ($class, %args) = @_;
if( $args{properties_file} )
{
$args{__name} =
reading: $!";
local $/;
$args{data} = decode_json(scalar(<$ifh>));
}
elsif( $args{json} )
{
$args{data} = decode_json($args{json});
$args{__name} = 'root';
}
elsif( $args{da
ta} )
{
$args{__name} ||= 'root';
}
else
{
die "Neither properties_file nor json nor data were provided.";
}# end if()
my $s = bless \%args, $class;
if( ref($s->{data}) eq 'HA
ole::Output::Json;
{
$App::PipeFilter::Role::Output::Json::VERSION = '0.005';
}
use Moose::Role;
use JSON::XS;
sub encode_output {
# Skips $self in $_[0].
return map { encode_json($_) . "\n"
E
App::PipeFilter::Role::Output::Json - serialize output as one JSON object per line
=head1 VERSION
version 0.005
=head1 SYNOPSIS
package App::PipeFilter::JsonToYaml;
use Moose;
extends '
peFilter::Role::Input::Json
App::PipeFilter::Role::Transform::None
App::PipeFilter::Role::Output::Yaml
);
1;
=head1 DESCRIPTION
App::PipeFilter::Role::Output::Json provides an encode_ou
Json;
{
$App::PipeFilter::Role::Input::Json::VERSION = '0.005';
}
use Moose::Role;
use JSON::XS;
has _json => (
is => 'rw',
isa => 'JSON::XS',
lazy => 1,
default => sub { JSON
) = $self->_json()->incr_parse($$buffer_ref);
$$buffer_ref = "";
return @return;
}
1;
__END__
=pod
=head1 NAME
App::PipeFilter::Role::Input::Json - parse input as a stream of JSON records
=h
ic::Json;
use Moose;
extends 'App::PipeFilter::Generic';
with qw(
App::PipeFilter::Role::Reader::Sysread
App::PipeFilter::Role::Input::Json
App::PipeFilter::Role::Output::Json
)
package App::PipeFilter::Generic::Json;
{
$App::PipeFilter::Generic::Json::VERSION = '0.005';
}
use Moose;
extends 'App::PipeFilter::Generic';
with qw(
App::PipeFilter::Role::Reader::Sysread
rint
App::PipeFilter::Role::Input::Json
App::PipeFilter::Role::Output::Json
);
1;
__END__
=pod
=head1 NAME
App::PipeFilter::Generic::Json - a generic JSON pipeline filter
=head1 VERSION
ver
::PipeFilter::JsonCat;
use Moose;
extends 'App::PipeFilter::Generic::Json';
with 'App::PipeFilter::Role::Transform::None';
1;
=head1 DESCRIPTION
App::PipeFilter::Generic::Json is a generic
package Log::JSON;
use Moose;
use MooseX::Types::Path::Class;
use Carp;
use DateTime;
use English;
use JSON;
use Path::Class::File;
our $VERSION = '0.001'; # VERSION
has 'date' => ( is => 'ro', isa
json = JSON->new->canonical->encode( \%data );
if ( $self->remove_newlines ) {
$json =~ s/\n//g;
$json =~ s/\r//g;
}
my $fh = $self->file->open('>>');
print $fh $json
Log data to a file as JSON
1;
__END__
=pod
=encoding utf-8
=head1 NAME
Log::JSON - Log data to a file as JSON
=head1 SYNOPSIS
use Log::JSON;
my $logger = Log::JSON->new(
file
package Sledge::Plugin::JSON::XS;
use strict;
use warnings;
use 5.00800;
use JSON::XS;
use Encode ();
our $VERSION = '0.05';
our $ConformToRFC4627 = 0;
our $ENCODING = 'utf-8';
sub import {
my $
pkg = caller(0);
no strict 'refs'; ## no critic.
*{"$pkg\::output_json_xs"} = \&_output_json_xs;
}
sub _output_json_xs {
my ($self, $src) = @_;
my $content_type =
( $self->d
e($self, $ENCODING );
my $json = encode_json($src);
my $output = _add_callback($self, _validate_callback_param($self, ($self->r->param('callback') || '')), $json );
$self->r->content_type
e JSON::HPack;
use common::sense;
use constant FIRST => 0;
use JSON::Any;
our $VERSION = q(0.0.3);
=head1 NAME
JSON-HPack - JSON Homogeneous Collections Compressor
=head1 SYNOPSIS
use JSON:
:HPack;
JSON::HPack->pack( [
{
name => 'Larry Wall',
nick => 'timtowtdi'
}
] );
# - OR -
JSON::HPack->dump( [
{
name => 'Larry Wall',
nick => 'timto
# To Unpack
JSON::HPack->unpack(
[ 2, 'name', 'nick', 'Larry Wall', 'timtowdi' ]
)
# - OR use JSON string directly
JSON::HPack->load( $json_string )
=head1 DESCRIPTION
JSON HPack perl i
package KinoSearch::Util::Json;
use KinoSearch;
1;
__END__
__COPYRIGHT__
Copyright 2005-2011 Marvin Humphrey
This program is free software; you can redistribute it and/or modify
under the same te
dexer::Output::JSON;
use strict;
use warnings;
use JSON::XS;
require IRC::Indexer::Output;
our @ISA = qw/IRC::Indexer::Output/;
sub dump {
my ($self) = @_;
$self->{Output} = JSON::XS->new->utf8
lf->{Output} = JSON::XS->new->utf8(1)->indent->encode(
$self->{Input}
) . "\n" ;
$self->SUPER::write($path);
}
1;
__END__
=pod
=head1 NAME
IRC::Indexer::Output::JSON - JSON::XS output sub
class
=head1 DESCRIPTION
L<IRC::Indexer::Output> subclass serializing via L<JSON::XS>.
See L<IRC::Indexer::Output> for usage details.
=head1 AUTHOR
Jon Portnoy <avenj@cobaltirc.org>
=cut
:Util::Json;
use Scalar::Util qw( blessed );
use KinoSearch qw( to_clownfish );
use KinoSearch::Util::StringHelper qw( utf8_valid utf8_flag_on );
use JSON::XS qw();
my $json_encod
_json {
my ( undef, %args ) = @_;
my $result;
my $instream = $args{folder}->open_in( $args{path} )
or return;
my $len = $instream->length;
my $json;
$instream->read( $json, $len );
if ( utf8_valid($json) ) {
utf8_flag_on($json);
$result = eval { to_clownfish( $json_encoder->decode($json) ) };
}
package JSON::RPC::Dispatcher::ClassMapping;
use strict;
use warnings;
our $VERSION = '0.03';
use JSON::RPC::Dispatcher 0.0505;
use Moose;
use namespace::autoclean;
# XXX: Hack to relax "method" co
nstraint of J::R::D::P so that it accepts "."
{
package
JSON::RPC::Dispatcher::Procedure; # hide from PAUSE/indexers
use Moose;
__PACKAGE__->meta->make_mutable;
has method => (
is => 'r
immutable;
}
has 'rpc' => (
is => 'rw',
isa => 'Object',
default => sub { JSON::RPC::Dispatcher->new },
handles => [ 'to_app', 'register' ],
);
has 'dispatch' => (
is
package Google::Data::JSON;
use warnings;
use strict;
use version; our $VERSION = qv('0.1.10');
use File::Slurp;
use JSON::Any;
use List::MoreUtils qw( any uniq );
use Perl6::Export::Attrs;
use Sto
$type eq 'json' || $type eq 'hash' || $type eq 'atom';
return __PACKAGE__->error("Bad stream: $type => $stream")
if ($type eq 'xml' && $stream !~ /^</)
|| ($type eq 'json' && $str
isa($stream, 'HASH') ? 'hash'
: $stream =~ /^\{/ ? 'json'
: $stream =~ /^</ ? 'xml'
: __PACKAGE__->error("Bad