ount descriptor URI is fetched via HTTP GET with an Accept header
asking for RDF/XML, Turtle, RDF/JSON or XRD. The result is parsed for account
description data if it has status code 200 (OK).
The fo
::MiJ;
use ex::monkeypatched;
use JSON;
use 5.006;
use strict;
use warnings FATAL => 'all';
=head1 NAME
MARC::Record::MiJ - Convert MARC::Record to/from marc-in-json structure
=head1 VERSION
Versi
my $str = get_marc_in_json_from_somewhere;
# The most common use will be to use methods monkeypatched into MARC::Record
my $r = MARC::Record->new_from_mij($str);
my $json = $r->to_mij;
# Yo
u can also work with the underlying hash/array structure if you're dealing with
# json serialization/deserialization on your own
my $mij_structure = $r->to_mij_structure;
my $r = MARC::Record->
;
use strict;
use warnings;
sub load_json {
my $file = shift;
open my $fh, "<", $file or die "$file: $!";
from_json(join '', <$fh>);
}
sub dump_json {
my($data, $file) = @_;
op
binmode $fh;
print $fh to_json($data);
}
sub from_json {
require JSON;
JSON::decode_json(@_);
}
sub to_json {
my($data) = @_;
require JSON;
JSON->new->utf8->pretty->canonical
package Mail::SendGrid::SmtpApiHeader;
use strict;
use warnings;
use JSON;
our $VERSION = '0.02';
sub new {
my $class = shift;
return bless { 'data' => { } }, ref $class || $class;
}
sub ad
$JSON;
sub asJSON {
my $self = shift;
$JSON ||= _build_json();
return $JSON->encode($self->{data});
}
my $JSON_PRETTY;
sub asJSONPretty {
my $self = shift;
$JSON_PRETTY ||= _build_json()
(1);
return $JSON_PRETTY->encode($self->{data});
}
sub as_string {
my $self = shift;
my $json = $self->asJSON;
$json =~ s/(.{1,72})(\s)/$1\n /g;
my $str = "X-SMTPAPI: $json";
return $s
heck> will warn you about
this:
$ carton check
Following dependencies are not satisfied.
JSON has version 2.51. Needs 2.52
Run `carton install` to install them.
You can run C<carton instal
ord::MiJ;
use base qw(MARC::File);
=head1 NAME
MARC::File::MiJ - Read newline-delimited marc-in-json files
=head1 VERSION
Version 0.04
=cut
our $VERSION = '0.04';
=head1 SYNOPSIS
Use by itsel
eader = new MARC::Batch('MiJ', $jsonfilename);
while (my $r = $batch->next) { ... }
# or, use it without MARC::Batch
my $reader = MARC::File::MiJ->in($jsonfilename);
=head1 DESCRIPTI
s newline-delimited marc-in-json,
as supported by pymarc/ruby-marc/marc4j and
described at http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json/.
=head1 SUBROUTINES/MET
;
builder {
enable 'FixIEXDomainRequestBug',
force_content_type => 'application/json';
$app;
};
=head2 Custom Provider
Use some custom code to provide a valid mimetype
my $env = shift;
if($env->{PATH_INFO} =~ m{^/api}) {
return 'application/json';
} else {
return 'application/x-www-form-urlencoded';
}
est->new($env);
## Assume a request url like "http://myapp.com/path?format=application/json"
return $req->query_parameters->get('format')
};
$app;
};
=head1 ATT
ect '"
. $proj->name
. "'.");
}
}
$self->add_json_header(update_nav => 1) if $dev->id == $self->developer->id;
return $self->devs({}, $proj);
}
removed from project '"
. $proj->name
. "'.");
}
$self->add_json_header(update_nav => 1) if $dev->id == $self->developer->id;
return $self->devs({}, $proj);
}
msg => "New project '" . $project->name . "' successfully created.");
}
return $self->add_json_header(list_changed => 1, update_nav => 1);
}
=head2 details
Show the details about a project.
use base 'Test::WWW::Mechanize';
use Smolder::Conf;
use Smolder::TestData qw(base_url);
use JSON qw(from_json);
use Test::Builder;
use Test::More;
=head1 NAME
Smolder::Mech
=head1 DESCRIPTION
L<T
return $self->SUPER::request(@_);
}
=head1 contains_message
This method will look in the C<X-JSON> HTTP header
of the response, look through each message in the
C<messages> array and see if any o
lf, $match) = @_;
my $resp = $self->response();
my $json = from_json($self->response->header('X-JSON') || '{}');
my $msgs = $json->{messages} || [];
my $diag = "contains message $match
her::WWO;
use Moo;
use MooX::Types::MooseLike::Base qw/Str Int HashRef Bool/;
use HTTP::Tiny;
use JSON;
our $VERSION = '0.07';
=head1 Name
Weather::WWO - API to World Weather Online
=head1 Synopsi
default => sub { 5 },
);
# We are only using the JSON format
has 'format' => (
is => 'ro',
isa => Str,
default => sub { 'json' },
init_arg => undef,
);
has 'temperature_
ponse->{content};
die "No content for $URL\n" unless defined $content;
my $data = decode_json($content);
# Are there any errors?
if (my $errors = $data->{data}->{error}) {
for
# ABSTRACT: provides perl API to Forecast.io
package Forecast::IO;
use strict;
use warnings;
use JSON;
use HTTP::Tiny;
use Moo;
my $api = "https://api.forecast.io/forecast";
my $docs = "https://de
se->{status} $response->{reason}\n"
unless $response->{success};
my $forecast = decode_json( $response->{content} );
while ( my ( $key, $val ) = each %args ) {
unless ( exists(
g => "User '" . $developer->username . "' has been successfully updated.");
return $self->add_json_header(list_changed => 1);
}
=head2 list
Show a list of all developers. Uses the F<Admin/Develo
ge(msg => "New user '" . $developer->username . "' successfully created.");
return $self->add_json_header(list_changed => 1);
}
=head2 delete
Delete a Developer and all data associated with him
::Log::LogDispatch> this can be thought of as a common logging interface.
package MyApp::View::JSON;
extends 'MyApp::View';
with 'MooseX::Role::LogHandler';
sub bar {
$self->logger->d
);
has 'decoder' => (
is => 'ro',
lazy => 1,
builder => sub {
require JSON;
return JSON->new();
},
);
has 'world' => (
is => ro =>,
required => 1,
);
has search
...
my $ua = $instance->ua();
=head2 C<decoder>
The C<JSON> Decoder object
my $instance = $class->new(
decoder => JSON->new()
);
=head2 C<world>
B<MANDATORY PARAMETER>:
$instance = $class->new( _ts => "mm-dd-yyy" );
=head2 C<_results>
Lazy builder that returns a C<json>-decoded version of the result of fetching C<uri>.
my $instance = $class->new( _results => {
trict;
use warnings;
use Carp ();
use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK SEEK_SET SEEK_END);
use JSON;
use Net::OAuth;
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
use URI;
use
t
request_token
request_secret
access_token
access_secret
root
no_decode_json
error
code
request_url
request_method
timeout
oauth_callback
callback
oaut
timeout => $args->{timeout} || (60 * 60 * 24),
no_decode_json => $args->{no_decode_json} || 0,
no_uri_escape => $args->{no_uri_escape} || 0,
env_proxy
ts;
if (ref $hosts eq 'CODE') {
return $hosts->();
}
return $hosts;
}
sub TO_JSON {
my $self = shift;
return {
name => $self->name,
hosts => $self->get_hos
oading file: %s", $@ || $!);
}
}
sub dump_config {
my $self = shift;
require JSON;
print JSON->new->pretty->utf8->allow_blessed(1)->convert_blessed(1)->encode({
config =>
ames>
=begin MetaPOD::JSON v1.1.0
{
"namespace":"Net::TribalWarsMap::API::TribeLookup::Result",
"interface":"class",
"inherits":"Moo::Object"
}
=end MetaPOD::JSON
=head1 AUTHOR
Kent
Application::Plugin::TT;
use CGI::Application::Plugin::LogDispatch;
use CGI::Application::Plugin::JSON qw(:all);
use Template::Plugin::Cycle;
use CGI::Cookie;
# This has nice output, but can't get it
gs) = @_;
my $msgs = $self->json_header_value('messages') || [];
push(@$msgs, {type => ($args{type} || 'info'), msg => ($args{msg} || '')});
$self->add_json_header(messages => $msgs);
}
=
} else {
return $html;
}
}
=head2 get_pref_details
This run mode will return a JSON header which contains the name-value
pairs for this preferences data.
=cut
sub get_pref_details
_ => $pref->$_ } qw(email_type email_freq email_limit show_passing);
}
return $self->add_json_header(%data);
}
=head2 update_pref
Update the information coming from the C<show> run mode.
If