eturn !!1 if is_plain_scalarref($value) && $$value == 1;
require JSON::PP;
return !!1 if JSON::PP::is_bool($value) && $value == JSON::PP::true();
return !!0;
}
sub is_false {
shift;
my ($value)
eturn !!1 if is_plain_scalarref($value) && $$value == 0;
require JSON::PP;
return !!1 if JSON::PP::is_bool($value) && $value == JSON::PP::false();
return !!0;
}
sub is_null {
return !defined $_[1
:SSL;
use LWP::UserAgent;
use HTTP::Request;
use MIME::Base64 qw();
use Net::SolarWinds::Log;
use JSON qw();
use URI::Encode qw(uri_encode);
use POSIX qw(strftime);
our $VERSION="1.22";
use base qw(
:JSON
This is a JSON object with the following options endabled: JSON->new->allow_nonref->utf8
=cut
# Global JSON OBJECT
our $JSON=JSON->new->allow_nonref->utf8;
=item * my $json=$class->get_json;
Returns the class level JSON object.
=cut
sub get_json { return $JSON; }
=item * $Net::SolarWinds::REST::UA
This is a LWP::UserAgent used to talk to CPM servers
=cut
# Global UA object
our $UA
=> {pygments => 'yaml'},
perl => {pygments => 'perl', sh => 'perl'},
json => {pygments => 'json', sh => 'js' },
js => {pygments => 'js' , sh => 'js' },
php
1 SEE ALSO
For syntax-highlighting (as well as encoding/formatting) to JSON, there's
L<JSON::Color> or L<Syntax::Highlight::JSON> (despite the module name, the
latter is an encoder, not strictly a st
rl.org/dist/Syntax-Highlight-Engine-Kate>),
L<Syntax::Highlight::JSON>
(L<reviews|http://cpanratings.perl.org/dist/Syntax-Highlight-JSON>),
L<Syntax::Highlight::Engine::Simple>
(L<reviews|http://cpanr
rep /;
my %content_types = (
yaml => 'text/x-yaml',
yml => 'text/x-yaml',
json => 'application/json',
dump => 'text/x-data-dumper',
'' => 'text/html',
);
# TODO check if we us
\w+)} => sub {
User->find(captures->{id});
};
# curl http://mywebservice/user/42.json
{ "id": 42, "name": "John Foo", email: "john.foo@example.com"}
# curl http://mywebservic
*> serializer. Unless overriden in the
configuration, it defaults to:
serializers:
json: JSON
yml: YAML
dump: Dumper
=head1 KEYWORDS
=head2 prepare_serializer_for_format
Wh
e
eng_name
tags
% curl 'http://localhost:5000/list_columns?table=countries&detail=1&-riap-fmt=json-pretty'
[
200,
"OK",
[
{
"pos" : 1,
"name" : "id",
"t
http://localhost:5000/api/list_tables
* Function arguments can be given via GET/POST params or JSON hash in req body
* To find out which arguments a function supports, try:
http://localhost:5
data, use the C<-riap-fmt>
special argument:
% curl http://localhost:5000/list_tables?-riap-fmt=json-pretty
[
200,
"OK",
[
"\"main\".\"continents\"",
"\"main\".\"countries\"",
w(:common);
use Data::Dumper;
use Text::Xslate qw(mark_raw);
use Encode;
use HTML::Entities;
use JSON;
use URI::Escape;
use Yote::Server;
sub new {
my( $pkg, %options ) = @_;
#
# Setup
sub handle_json_request {
my( $self, $req ) = @_;
my $json_payload = uri_unescape(scalar($req->param('p')));
my $in_json = decode_json( $json_payload );
my( $out_json, @uploads );
$out_json = $self->{server}->invoke_payload( $json_payload, \@uploads );
};
if( $@ ) {
my $err = ref $@ ? $@ : { err => "INTERNAL ERROR" };
$out_json = to_json( $err );
ict mode, override it and return false value.
SEE ALSO: L<The JSON SQL Injection Vulnerability|http://blog.kazuhooku.com/2014/07/the-json-sql-injection-vulnerability.html>
=head3 C<preload_all_row_c
teTime->dmy . ' ' .
DateTime->hms). This is to make it easy to pass the data structure into YAML,
JSON, MySQL, etc. Nevertheless, internally DateTime objects are still used.
=back
Additional notes:
t
$HTML::FormHandler::Render::RepeatableJs::VERSION = '0.40068';
use Moose::Role;
use JSON::MaybeXS ('encode_json');
sub render_repeatable_js {
my $self = shift;
return '' unless $self->has
_js->{$key}->{level};
}
my $index_str = encode_json( \%index );
my $html_str = encode_json( \%html );
my $level_str = encode_json( \%level );
my $js = <<EOS;
<script>
\$(document).
{
require File::Temp;
require JSON::MaybeXS;
#require String::ShellQuote;
my $data = shift;
state $json = JSON::MaybeXS->new->allow_nonref;
# code t
js
my $src = "var formatter = $code;\n\n".
"console.log(JSON.stringify(formatter(".
$json->encode($data).")))";
my ($jsh, $jsfn) = File::Temp::tempfile();
file $jsfn: $!";
my $out = IPC::System::Options::readpipe($nodejs_path, $jsfn);
$json->decode($out);
};
}
1;
# ABSTRACT: Generate formatter code
__END__
=pod
=encoding UTF-8
t->get_data;
my $node_id=$node->{NodeID};
return $self->UpdateNodeProps($node_id,UnManaged=>&JSON::true);
}
=item * my $result=$self->get_management_config($thing);
Programatic way build a refr
mes,
custom_properties=>$custom_props,
templates=>$templates,
};
$config->{replace}=&JSON::false;
return $self->RESULT_CLASS->new_true($config);
}
=item * my $result=$self->get_poller_
elium');
Make a URL for the Wikidata page. You will then need to retrieve the
page and parse the JSON yourself. Use a second argument to specify the
language of the page:
use utf8;
use
%B8%AE%E0%B8%B5%E0%B9%80%E0%B8%A5%E0%B8%B5%E0%B8%A2%E0%B8%A1&props=sitelinks/urls|datatype&format=json
(This example is included as L<F<thai-url.pl>|https://fastapi.metacpan.org/source/BKB/WWW-Wikip
ent
L<LWP::UserAgent> is used to retrieve the data from Wikidata.
=item JSON::Parse
L<JSON::Parse> is used to parse the JSON data from Wikidata.
=item URI::Escape
L<URI::Escape> is used to make t
);
use File::Temp qw(tempfile tempdir);
use File::Which;
use IPC::System::Options qw(system);
use JSON::MaybeXS;
use List::Util qw(first);
use Moose;
with (
'Dist::Zilla::Role::FileFinderUser' =>
$self->write_modules_to_dir;
my $mods_tempdir = $self->written_modules_dir;
# the --json output is so that we can read the list of included modules
my @depak_cmd = (
"depak",
"--include-dir", $mods_tempdir,
"-i", $source, "-o", $target, "--overwrite",
"--json",
);
if (-f "depak.conf") {
push @depak_cmd, (
"--config-profile", $
K,
);
our $VERSION = '0.04';
use LWP::UserAgent;
use URI::Escape 'uri_escape_utf8';
use JSON::Parse 'parse_json';
sub make_wiki_url
{
my ($name, $lang) = @_;
if (! $lang) {
# Defaults to En
w/api.php?action=wbgetentities&sites=$lang&titles=$safe_name&props=sitelinks/urls|datatype&format=json";
return $url;
}
sub get_wiki_titles
{
my ($name, %options) = @_;
my $lang = $option
print "$name data was retrieved successfully.\n";
}
my $json = $response->decoded_content ();
my $data = parse_json ($json);
my $array = $data->{entities};
my %lang2title;
for
e, to be able to specify
the probe arguments as JSON. This is inspired by
the Varnish probe config block:
# This is my config file.
# It's JSON presumably...
"backends": {
"1.2.3
Pipe)
=head2 (Client) (Socket)
=head2 (Client) (Server) Dealing with binary data
The choice as JSON as the network transport protocol (because it is the lowest
common denominator across languages l
this function via Riap in-process, there's nothing to worry about
since there is no round-trip to JSON. You can just:
my $res = Perinci::Access->new->request(call => "/MyLib/gzip",
=>{data=>"some data"}});
If you are using this function over HTTP or oher network protocol where JSON is
involved, you will need to encode the argument:
use MIME::Base64;
my $res = Perinci::Access
e::CastleIO;
use 5.10.0;
use strict;
use warnings;
use feature 'switch';
use feature 'say';
use JSON;
use REST::Client;
use MIME::Base64;
use Moose;
use Moose::Util::TypeConstraints;
use MooseX::Pa
/api.castle.io/v1'
);
has format => (
is => 'ro',
isa => 'Str',
default => 'json'
);
has cookie_id => (
is => 'rw',
isa => 'Str'
);
has ip_address => (
is
Vjnn',
cookie_id => 'abcd',
ip_address => '24.61.128.172',
headers => JSON->new->allow_nonref->utf8->encode({'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.
alized';
no warnings 'numeric';
use Lock::Server;
use Yote;
use bytes;
use IO::Socket::SSL;
use JSON;
use Time::HiRes qw(time);
use URI::Escape;
use UUID::Tiny;
use vars qw($VERSION);
$VERSION =
$sock->close;
exit;
}
# data has the input parmas in JSON format.
# POST /
if ( $verb ne 'POST' ) {
$sock->print( "HTTP/1.1 40
p=//;
my $out_json;
eval {
$out_json = $self->invoke_payload( $data );
};
if( ref $@ eq 'HASH' ) {
$out_json = encode_json( $@ );
}
Base/lib';
use Yote;
use Yote::Server;
use CGI;
use DateTime;
use Data::Dumper;
use Encode;
use JSON;
use URI::Escape;
sub _log {
my( $msg ) = @_;
open my $out, ">>/opt/yote/log/yote.log";
re_locker;
}
my $cgi = CGI->new;
# check if a file upload
my $json_payload = uri_unescape(scalar($cgi->param('p')));
_log( "IN : '$json_payload'" );
my $uploads = $cgi->param('f');
my( @uploads );
i
e FILE;
}
}
my $out_json;
eval {
$out_json = $main::yote_server->invoke_payload( $json_payload, \@uploads );
};
if( ref $@ eq 'HASH' ) {
$out_json = encode_json( $@ );
undef $@;
} e
Linux version 3.16.0-4-amd64 >>.
Benchmark with C<< bencher -m LogAny::NullLogging --env-hashes-json '[{"PERL5OPT":"-Iarchive/Log-Any-1.040/lib"},{"PERL5OPT":"-Iarchive/Log-Any-1.041/lib"}]' >>:
#