ern::Perl;
use Digest::MD5 qw( md5_hex );
use File::Find;
use File::stat;
use HTTP::Lite;
use JSON;
use version;
our $VERSION = qv( 1.0.1 );
use constant BASE_URI => 'http://discident.com/v1';
unless 200 == $code;
return $http->body()
if $raw;
return from_json $http->body()
}
sub query_url {
my $self = shift;
my $ident = shift // $self->ident();
hods here are not sufficient for you or if you have
to output something different than HTML (e.g. JSON or XML).
The structure returned will look like this (based on our
example above with some data f
f ! exists $result->{$col_meta->{field_name}};
}
return {%{$self->{embed}}, %$result};
}
*TO_JSON = \&hash;
*TO_XML = \&hash;
sub embed {
my $self = shift;
my $what = shift;
if (@_ == 1) {
TP;
use Digest::HMAC_SHA1 qw(hmac_sha1 hmac_sha1_hex);
use LWP::UserAgent;
use HTTP::Request;
use JSON;
use WWW::DNSMadeEasy::Domain;
our $VERSION ||= '0.0development';
has api_key => (
is => 'ro'
request->header('Accept' => 'application/json');
if (defined $data) {
$request->header('Content-Type' => 'application/json');
$request->content(encode_json($data));
}
my $res = $self->_http_age
nt->request($request);
if ($res->is_success) {
return decode_json($res->content);
} else {
die __PACKAGE__.' HTTP request failed: '.$res->status_line, "\n";
}
}
#
# DOMAINS
#
sub path_domains
uthorization grant
... send token request
# receive token
#
my %params = ... decode from JSON, URI fragment, etc...
my ($error, @token) = $access_scheme->token_accept(%params)
... complai
ear in a successful token or authorization
endpoint response (i.e., prior to being encoded into a JSON structure
or URI fragment on the authorization server, or, equivalently, after
such decoding on t
$fixed_length, $help, $json );
my ( $sfile, $stfile );
my $error = '';
parse_options( $params_array, \$error, \$check, \$file, \$fixed_length,
\$help, \$json );
return <<EOF
ut as fixed length fields
-h, --help prints this help and exits
-j, --json prints output as json
EOF
if ($parser_class) {
eval "require $parser_class";
}
els
ass->new( file => $file_name ); };
return "Parsing error: $@\n" if $@;
return json_dump($cfg) if $json;
my @output = deep_dump( [], $cfg, \@errors );
my $output = ( $check && scalar
ension,
isInterbase => ($self->is_interbase ? "true" : "false"),
};
return $self->json->encode($query);
}
=head2 get_list_request_parameters(List[Str => Str])
Returns the request par
= shift;
return $self->_sequence_results("gff3");
}
with 'Webservice::InterMine::Role::KnowsJSON';
with 'Webservice::InterMine::Role::Listable';
no Moose;
__PACKAGE__->meta->make_immutable();
$self;
}
sub render
{
my ( $self, $data ) = @_;
if ($self->{'format'} eq 'JSON') {
TRACE ( "Rendering to JSON" );
DUMP ( $data );
return Data::JavaScript::Anon->anon_dump ( $data )
late
{
return 0;
}
sub available_formats
{
return [ "JavaScript::Anon", "Javascript::Anon", "JSON" ];
}
sub TRACE {}
sub DUMP {}
1;
=head1 NAME
Any::Renderer::JavaScript::Anon - renders anony
JSON
Use the format 'JSON' to return completely anonymous data structures - i.e. with no leading
"var script_output = " and no trailing ";"
perl -MAny::Renderer -e "print Any::Renderer->new('JSON
tmagic.com/
package Net::SMS::TextMagic;
use strict;
use warnings;
our $VERSION = '1.00';
use JSON;
use LWP::UserAgent;
use URI::Escape qw(uri_escape uri_escape_utf8);
use Encode qw(encode decode)
_json = contact_api($class, 'send', %params);
if (defined($r_json)) {
# No errors
my %response = ();
$response{'sent_text'} = $r_json->{'sent_text'};
$response{'parts_count'} = $r_json
->{'parts_count'};
while (my ($id, $number) = each %{$r_json->{"message_id"}} ) {
$response{'message_id'}{$number} = $id;
}
return %response;
}
else {
# Errors, we expect that err
ware
# framework that handles all text-related
# information extracted from an EML or XML
# or JSON data file. This allows the VoteFair
# Ranking software to just handle numbers
# (and a few err
encode decode/;
use LWP::UserAgent;
use HTML::TreeBuilder;
use HTML::Element;
use XML::Smart;
use JSON;
use YAML qw(Dump);
use utf8;
use Carp;
my %area_zh = (
'台北市' => '36_01_data.htm'
my $weather = Weather::TW->new;
my $xml = $weather->area('Taipei City')->xml;
my $json = $weather->json;
my $yaml = $weather->yaml;
my %hash = $weather->hash;
foreach my $area (
PTION
This module parse data from L<http://www.cwb.gov.tw/> (中央氣象局), and generates xml/json/hash/yaml data.
=head1 OLD METHODS
=over
=item C<< new >>
Create a new C<Weather::TW> object.
e:
use PerlX::QuoteOperator::URL 'qh';
use JSON qw(decode_json);
say decode_json( qh{ http://twitter.com/statuses/show/6592721580.json } )->{text};
# => "He nose the truth."
=
structures.
=cut
use strict;
use warnings;
use Carp;
use HTTP::Request;
use LWP::UserAgent;
use JSON::Any;
our $VERSION = '0.02';
our $states = { 'ok' => 0, 'warning' => '1', 'critical' => '2', 'u
;
$self->{'_url'} = $self->_get_url();
$self->{'_ua'} = LWP::UserAgent->new;
$self->{'_json'} = JSON::Any->new;
return $self;
}
sub _get_url {
my $self = shift;
return sprintf('%s://%s/
sword'});
my $req = HTTP::Request->new( GET => $url );
$req->header( 'Content-Type' => 'text/json' );
$req->header( 'X-Username' => $self->{'user'} );
$req->header( 'X-Password' => $self->{'p
include:
- XML (via XML::Simple)
- XML+XSLT
- Data::Dumper
- Javascript, Javascript::Anon & JSON
- UrlEncoded
- The formats supported by Data::Serializer (e.g. Config::General and Config::Wres
'application/sparql-results+xml', undef, 'utf-8'],
[WWW::DataWiki::FMT_RS_JSON, 0.9, 'application/x-sparql-results+json', undef, 'utf-8'],
[WWW::DataWiki::FMT_RS_TEXT, 0.6, 'text/plain', undef
s+xml',
'.xhtml'=> 'application/xhtml+xml',
'.html' => 'text/html',
'.json' => 'application/x-sparql-results+json',
'.txt' => 'text/plain',
'.csv' => 'text/csv',
'.tab' => 'text/t
s_string_as ($fmt)
{
my $str;
given ($fmt)
{
when (WWW::DataWiki::FMT_RS_JSON) { $str = $self->rs->as_json; }
when (WWW::DataWiki::FMT_RS_XML) { $str = $self->rs->as_xml; }
when (WW
WWW::DataWiki::FMT_NT, 0.6, 'text/plain', undef, 'utf-8'],
[WWW::DataWiki::FMT_JSON, 0.6, 'application/json', undef, 'utf-8'],
[WWW::DataWiki::FMT_XML, 0.6, 'application/rdf+xml',
ation/rdf+xml',
'.xhtml'=> 'application/xhtml+xml',
'.html' => 'text/html',
'.json' => 'application/json',
};
}
method rdf_string_conforms_to ($format)
{
return 1 if $format eq WWW::
any type of file supported by L<Config::Any|Config::Any>: Apache config style (Config::General), JSON, INI files, XML, YAML or perl code.
Here is an example of a configuration file that uses L<Confi
===============
BEGIN {
__PACKAGE__->_define(
type => 'member',
ro => [qw(accounts:JSON sites:JSON)],
);
} # end BEGIN
#===================================================================
-9-]*[a-z0-9])(?:/[a-z][a-z0-9-]*[a-z0-9])*)';
our $RE_ext = '(\.nt|\.n3|\.ttl|\.x?html|\.xml|\.json|\.txt|\.csv|\.tab)';
our $RE_path = "${RE_page}${RE_ext}?";
our $RE_vid = '(\d{4}(?:\d{2}(?:\d
plication/sparql-update, text/n3, text/turtle, text/plain, application/rdf+xml;q=0.5, application/json;q=0.1, application/xhtml+xml;q=0.1, text/html;q=0.1'});
}
}
action wikipage_PATCH
{
my ($
s.',
{'X-Accept' => 'text/n3, text/turtle, text/plain, application/rdf+xml;q=0.5, application/json;q=0.1, application/xhtml+xml;q=0.1, text/html;q=0.1'});
}
}
action wikipage_DELETE
{
my (
=> 'account',
ro => [qw(balance balanceCash balanceCredit balanceHigh
status:JSON sites:JSON)],
rw => [qw(friendlyName)],
methods => {
addSite => [qw(site)],