my $p = param('positions') or send_error('Missing positions', 400);
my $positions = from_json($p) or send_error('Bad positions', 400);
send_error('Bad positions', 400) unless ref [] eq re
,
vlan => ($vlan || 0),
});
if ($posrow) {
$posrow->update({ positions => to_json(\%clean) });
}
else {
schema(vars->{'tenant'})->resultset('NetmapPositions')->creat
],
locations => [sort @lgrplist],
vlan => ($vlan || 0),
positions => to_json(\%clean),
});
}
};
sub make_node_infostring {
my $node = shift or return '';
my $f
sults;
if ( request->is_ajax ) {
my $json = to_json( \@results );
template 'ajax/report/devicednsmismatch.tt', { results => $json }, { layout => 'noop' };
}
else {
rom_json( decode_base64( $job->extra || '' ) );
$job->subaction('');
my $event_data = $extra->{'event_data'};
my $action_conf = $extra->{'action_conf'};
$action_conf->{'body'} ||= to_json($e
ustom_headers'} ||= {};
$action_conf->{'custom_headers'}->{'Content-Type'}
||= 'application/json; charset=UTF-8';
$action_conf->{'custom_headers'}->{'Authorization'}
= ('Bearer '. $action_
}
else {
my $stanza = undef;
try {
$stanza = from_json( $line );
debug sprintf '[%s] external credentials stanza added',
$
$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->{'
e from file or copy from job param
my $data = $job->extra;
my @arps = (length $data ? @{ from_json($data) } : ());
return $job->cancel('data provided but 0 arp entries found')
unless scalar
ven
if ( my $filename = $options->{'dictionary_location'} ) {
require Cpanel::JSON::XS;
open( my $fh, '<', $filename ) || die "Can't open [$filename]";
my $
, (<$fh>);
close $fh;
$options->{'dictionary'} = Cpanel::JSON::XS::decode_json($input);
} else {
## no critic (ProhibitPackageVars)
require Gher
rd).
Mutually exclusive with C<dictionary_location>.
=item * dictionary_location
Pathname to a JSON file which deserializes into the structure mentioned
for the C<dictionary> option.
Mutually excl
ToJSON});
# this replacement will avoid the issue of relation names which override
# field names, causing TO_JSON to return object instances, breaking to_json
*DBIx::Class::Helper::Row::ToJSON:
:TO_JSON = sub {
my $self = shift;
my $columns_info = $self->columns_info($self->serializable_columns);
my $columns_data = { $self->get_columns };
return {
map +($_ =>
$columns_data->{$_}), keys %$columns_info
};
};
}
# for DBIx::Class::Helper::Row::ToJSON
# to allow text columns to be included in results
sub unserializable_data_types {
return {
to write a custom formatter, in our
case a JSONL formatter.
=head1 DESCRIPTION
This tutorial explains a minimal formatter that outputs each event as a json
string on its own line. A true formatter w
package Test2::Formatter::MyFormatter;
use strict;
use warnings;
use JSON::MaybeXS qw/encode_json/;
use base qw/Test2::Formatter/;
sub new { bless {}, shift }
sub encod
ite {
my ($self, $e, $num, $f) = @_;
$f ||= $e->facet_data;
print encode_json($f), "\n";
}
1;
=head1 LINE BY LINE
=over 4
=item use base qw/Test2::Formatter/;
All
s::Message';
has 'prop1';
has 'prop2';
=head1 DESCRIPTION
=cut
use Carp qw(croak);
use JSON::MaybeXS;
use Scalar::Util qw( blessed );
use Moo;
# 'use Moo' implies 'use strict; use warning
ncy tree for the Cucumber::Messages
# library, I decided to go for Moo instead of Moose.
my $json = JSON::MaybeXS->new(
utf8 => 0, pretty => 0, indent => 0, canonical => 1
);
sub _camelize
? JSON::MaybeXS->true : JSON::MaybeXS->false;
}
}
}
sub _from_hash {
my ($value, %args) = @_;
if (my $ref = ref $value) {
return $value ? 1 : ''
if $json->i
a::Dumper::Indent=1;
use HTML::Entities qw(decode_entities encode_entities);
use CGI::Simple;
use JSON;
use Cwd qw(getcwd);
# Inherit from the Compile module, not loaded until needed though.
#
@ISA
" tags
#
%CGI_TAG_WEBDYNE=map {$_ => 1} (
'block',
'perl',
'subst',
'dump',
'json',
'api',
'include',
'htmx'
);
# Var to hold package wide hash, for data shared ac
}
else {
# html/text/json must be a param
#
my $html_sr=$param_hr->{'html'} || $param_hr->{'text'} || $param_hr->{'json'} ||
return err('no data suppl
ry {
my $ua = LWP::UserAgent->new;
$ua->default_header('Accept' => 'application/json');
# Path to the VERSION file
my $version_file_path = 'VERSION';
#
am;
$self->{'cnt'}++;
}
}
} else { #EXTRACT PODCAST PAGE DATA FROM EMBEDDED, ENCODED JSON:
$html = HTML::Entities::decode_entities($html);
$html = uri_unescape($html);
$html =~ s#\\
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
use 5.006;
use strict;
use warnings;
use Cache::LRU;
use LWP::UserAgent;
use HTTP::Headers;
use JSON;
use Geo::DetailsCore;
use Net::CIDR;
use Net::CIDR::Set;
our $VERSION = '3.2.0';
use constant D
/Perl/3.2.0' );
$header->header( 'Accept' => 'application/json' );
$header->header( 'Content-Type' => 'application/json' );
if ($token) {
$header->header( 'Authorization' =>
_type =~ m{application/json}i ) {
eval { $info = from_json( $response->decoded_content ); };
if ($@) {
return ( undef, 'Error parsing JSON response.' );
reference
my $self = { $key => $data };
bless $self, $class;
return $self;
}
sub TO_JSON {
my ($self) = @_;
return {%$self};
}
sub ip { return $_[0]->{ip}; }
sub hostname { retu
306741546438020584b9
my $tryStream = "https://opml.radiotime.com/Tune.ashx?id=$stationID&render=json";
print STDERR "-2 (we're a station) FETCHING URL=$tryStream=\n" if ($DEBUG);
my $response =
FAILED, INVALID STATION URL, PUNT!
my $json = '';
$json = $1 if ($html =~ s#\btype\=\"application\/json\"\>\{(.+)##s);
if ($json) {
print STDERR "..JSON data found, fetching data we can here fi
;
my $podcastdata = ($json =~ s#^(.+?)\"episodes\"\:##s) ? $1 : '';
while ($json =~ s#^.+?\"title\"\:\"([^\"]+)\"##so) {
my $epititle = $1;
my $epistream = ($json =~ m#\"file\_url\"\:\"(
($epititle && $epistream);
next if ($self->{'secure'} && $epistream !~ /^https/o);
if ($json =~ m#\"url\"\:\"([^\"]+)\"#so) {
$have1stepisode ||= $1;
$epistream =~ s/\.(mp3|m3u8|pl
#STEP 1 FAILED, INVALID PODCAST URL, PUNT!
if ($html =~ m#\<script\s+type\=\"application\/ld\+json"\>(.+?)\<\/script\>#s) {
my $epidata = $1;
if ($epidata =~ m#\"associatedMedia\"\:\{([^\}]+
on\/ld\+json\"\>\s*\{([^\}]+)#s) {
my $jsonstuff = $1;
my $streams = '';
$self->{'title'} = $1 if ($jsonstuff =~ m#\"name\"\:\s*\"([^\"]+)#s);
#x $self->{'description'} = $1 if ($jsonstuff =~
if ($jsonstuff =~ m#\"thumbnailUrl\"\:\s*\"([^\"]+)#s);
($self->{'imageurl'} = $self->{'iconurl'}) =~ s#^.+?(https?\:\/.+)$#$1#i
if ($self->{'iconurl'});
$self->{'year'} = $1 if ($jsonstuff