package Sledge::Plugin::JSON;
use warnings;
use strict;
use JSON::Syck;
our $VERSION = '0.01';
our $ConformToRFC4627 = 0;
sub import {
my $self = shift;
my $pkg = caller;
no strict 'r
efs';
*{"$pkg\::output_json"} = \&_output_json;
}
sub _output_json {
my ($self, $args) = @_;
my $encoding = $args->{encoding} ? $args->{encoding} : 'utf-8';
my $content_type =
self, $encoding );
my $json = JSON::Syck::Dump($args->{data});
my $output = _add_callback($self, _validate_callback_param($self, $self->r->param('callback')), $json );
$self->r->content_
package Plagger::Plugin::Publish::JSON;
use strict;
use base qw( Plagger::Plugin );
use File::Spec;
use JSON::Syck;
use Plagger::Walker;
use Plagger::Util;
sub init {
my $self = shift;
$self
| '%i.json');
my $path = File::Spec->catfile($self->conf->{dir}, $file);
$context->log(info => "writing output to $path");
local $JSON::Syck::ImplicitUnicode = 1;
my $body = JSON::Syc
conf->{varname}) {
$body = "var $var = $body;";
} elsif (my $jsonp = $self->conf->{jsonp}) {
$body = "$jsonp($body)";
}
$context->log(info => "Serializing " . $args->{feed
package EVDB::API::JSON;
use strict;
use warnings;
use Carp;
=head1 NAME
EVDB::API::JSON - Use the JSON flavor of the Eventful API
=head1 SYNOPSIS
my $evdb = EVDB::API->new(app_key => $app
-001336058-5' });
=head1 DESCRIPTION
Parses JSON from the Eventful API.
=head1 METHODS
=head2 flavor
Return the flavor name.
=cut
sub flavor { 'json' }
=head2 ctype
Return a checkstring for t
content type.
=cut
sub ctype { 'javascript' }
=head2 parse
Parse JSON data from the Eventful API using L<JSON::Syck> or L<JSON>.
=cut
sub parse {
my ($class, $data, $force_array) = @_;
ckage Kwiki::JSON;
use warnings;
use strict;
use Kwiki::Plugin '-Base';
use mixin 'Kwiki::Installer';
our $VERSION = '0.01';
const class_title => 'JSON Library';
const class_id => 'json';
const java
> 'json.js';
sub register {
my $registry = shift;
$registry->add(preload => 'json', priority => 1);
}
1; # End of Kwiki::JSON
__DATA__
=head1 NAME
Kwiki::JSON - Provides the JSON j
S
The developers of the JSON language as well as the many implementations of
JSON. It is great to have data structures than can be understood by all
languages and without JSON many of my project woul
package Data::Phrasebook::Loader::JSON::Syck;
use strict;
use warnings;
use Carp 'croak';
use JSON::Syck ();
use File::Slurp ();
use Data::Phrasebook;
our $VERSION = '0.01';
use base 'Da
not be found";
my $json = File::Slurp::slurp($filename) or croak "Could not slurp JSON file '$filename' got no data";
my $d = JSON::Syck::Load($json);
(ref($d) eq 'HASH')
JSON file '$filename'";
$class->{JSON} = $d;
}
sub get {
my ($class, $key) = @_;
return undef unless $key;
return undef unless $class->{JSON};
$class->{JSON}->{$key};
}
#sub dicts {
ackage JSON::Syck;
use strict;
use Exporter;
use DynaLoader;
our $VERSION = '0.07';
our @EXPORT_OK = qw( Dump Load );
our @ISA = qw( Exporter DynaLoader );
__PACKAGE__->bootstrap;
$JSON::Syck
g = 1;
$JSON::Syck::Headless = 1;
$JSON::Syck::ImplicitUnicode = 0;
$JSON::Syck::SingleQuote = 0;
1;
__END__
=head1 NAME
JSON::Syck - JSON is YAML
=head1 SYNOPSIS
use JSON::Syck;
my $data = JSON::Syck::Load($json);
my $json = JSON::Syck::Dump($data);
=head1 DESCRIPTION
JSON::Syck is a syck implementatoin of JSON parsing and
generation. Because JSON is YAML
(L<http://redh
Plugin::Config::JSON;
use strict;
use warnings;
use UNIVERSAL 'isa';
use NEXT;
use JSON;
use Path::Class 'file';
our $VERSION = '0.03';
=head1 NAME
Catalyst::Plugin::Config::JSON - Configure you
r Catalyst application via an external
JSON file
=head1 SYNOPSIS
use Catalyst 'Config::JSON';
__PACKAGE__->config('config_file' => 'config.json');
=head1 DESCRIPTION
This Catalyst plu
gin enables you to configure your Catalyst application with an
external JSON file instead of somewhere in your application code.
This is useful for example if you want to quickly change the configur
t data, multiple in/out formats, IP security, role based access
# Multiple input/output formats : json , xml , yaml, perl , human
#
# George Bouras , george.mpouras@yandex.com
# Joan Ntzougani, ✞
p
anel::JSON::XS; my $JSON = Cpanel::JSON::XS->new; $JSON->utf8(1); $JSON->indent(0); $JSON->canonical(0); $JSON->pretty(0); $JSON->max_size(0); $JSON->space_before(0); $JSON->space_after(1); $JSON->rel
axed(0); $JSON->allow_tags(1); $JSON->allow_unknown(0); $JSON->shrink(0); $JSON->allow_nonref(0); $JSON->allow_blessed(0); $JSON->convert_blessed(0); $JSON->max_depth(1024);
use YAML::XS; my $
ip => $device->addr,
-bool => \q{ jsonb_typeof(value) = 'array' },
})->hri->all;
send_error(
lar @rows;
my @snmpwalk = ();
foreach my $row (@rows) {
$row->{value} = (@{ from_json($row->{value}) })[0];
if (ref {} eq ref $row->{value}) {
foreach my $k (keys
push @new_dcf, $field;
next;
}
# snmp_object implies JSON content in the field
$field->{'json_list'} = true;
# snmp_object implies user should not edit in the web
type => 'exec',
event => 'discover',
with => {
# get JSON format of the snmp_object
cmd => (sprintf q![%% ndo %%] show -d '[%% ip %%]' -e %s --
if type=="string" then [.] else . end | [ .[] ] | sort'!
# send the JSON output into device custom_field (action inline)
.q! | [%% ndo %%] %s
est->remote_address,
log => $log,
});
});
content_type('application/json');
to_json({});
};
ajax '/ajax/userlog' => require_login sub {
my @jobs = jq_userlog( session('
t;/; $_}
map { $_->log }
grep { $_->status eq 'error' }
grep { defined }
@jobs
],
);
content_type('application/json');
to_json(\%status);
};
true;
$cf = from_json ($item->custom_fields || '{}');
}
elsif (ref {} eq ref $item and exists $item->{'custom_fields'}) {
$cf = from_json ($item->{'custom
$cf = from_json ($item->custom_fields || '{}');
}
elsif (ref {} eq ref $item and exists $item->{'custom_fields'}) {
$cf = from_json ($item->{'
with application protocols such as SNMP, NETCONF
(OpenConfig with XML), RESTCONF (OpenConfig with JSON), eAPI, or even CLI
scraping. The combination of transport and protocol is known as a I<driver>.
e->headers('Location' => $destination);
};
# neater than using Dancer::Plugin::Res to handle JSON differently
*Dancer::send_error = sub {
my ($body, $status) = @_;
if (request_is_ap
efined $body;
Dancer::Continuation::Route::ErrorSent->new(
return_value => to_json { error => $body, return_url => param('return_url') }
)->throw;
}
Dancer::Con
ta structure for DataTables records per page menu
$tokens->{table_showrecordsmenu} =
to_json( setting('table_showrecordsmenu') );
# linked searches will use these default url path param
schema(vars->{'tenant'})->resultset('DeviceSkip')
->get_distinct_col('backend');
return to_json \@names;
};
swagger_path {
tags => ['Queue'],
path => (setting('api_base') || '').'/queue/jo
=> (param('limit') || setting('jobs_qdepth') || 50),
})->with_times->hri->all;
return to_json \@set;
};
swagger_path {
tags => ['Queue'],
path => (setting('api_base') || '').'/queue/jobs
),
( param('backend') ? ( backend => param('backend') ) : () ),
})->delete;
return to_json { deleted => ($gone || 0)};
};
swagger_path {
tags => ['Queue'],
path => (setting('api_base'
,
},
"seen_on_router_first",
{ data_type => "jsonb", is_nullable => 0, default_value => \"{}" },
"seen_on_router_last",
{ data_type => "jsonb", is_nullable => 0, default_value => \"{}" },
"host($args->{foreign_alias}.ip)" => { '=' =>
\q{(SELECT key FROM json_each_text(seen_on_router_last::json) ORDER BY value::timestamp DESC LIMIT 1)} },
};
},
{ join_type => 'LE
_rs({}, {
'+columns' => [
{ router_ip => \q{(SELECT key FROM json_each_text(seen_on_router_last::json) ORDER BY value::timestamp DESC LIMIT 1)} },
{ router_name => \q{COAL
t'})->resultset('DeviceSkip')->get_distinct_col('backend');
content_type 'application/json';
to_json \@backends;
};
ajax '/ajax/data/queue/typeahead/username' => require_role admin => sub {
enant'})->resultset('Admin')->get_distinct_col('username');
content_type 'application/json';
to_json \@users;
};
ajax '/ajax/data/queue/typeahead/action' => require_role admin => sub {
m
meta( param('query') || param('term') || param('action') );
content_type 'application/json';
to_json [
grep { $q ? m/^$q/ : true }
grep { defined }
List::MoreUtils::uniq
est_is_api
Client has requested JSON format data and an endpoint under C</api>.
=cut
sub request_is_api {
return ((request->accept and request->accept =~ m/(?:json|javascript)/) and (
index(r
th
or request->path eq uri_for('/logout')->path
or request->path eq uri_for('/swagger.json')->path
or index(request->path, uri_for('/swagger-ui')->path) == 0
);
# Dancer wil
> {
'application/json' => { api_key => 'cc9d5c02d8898e5728b7d7a0339c0785' } } },
},
},
post '/login' => sub {
my $api = ((request->accept and request->accept =~ m/(?:json|javascript)/) ? tru
n => \'LOCALTIMESTAMP' });
if ($api) {
header('Content-Type' => 'application/json');
# if there's a current valid token then reissue it and reset timer
$