::SuccessfulResponseAsObject;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON::MaybeXS qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Da
f = shift;
my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
return $_hash;
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $
serialize the data
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
my $_is_nullable = ($self->openapi_nullable->{
t::ApiDiscoveryResponseLinks;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON::MaybeXS qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Da
f = shift;
my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
return $_hash;
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $
serialize the data
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
my $_is_nullable = ($self->openapi_nullable->{
iDiscoveryResponseLinksLinks;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON::MaybeXS qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Da
f = shift;
my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
return $_hash;
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $
serialize the data
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
my $_is_nullable = ($self->openapi_nullable->{
:ApiDiscoveryResponseService;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON::MaybeXS qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Da
f = shift;
my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
return $_hash;
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $
serialize the data
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
my $_is_nullable = ($self->openapi_nullable->{
p()->then(sub($result) {
$self->render(json => { data => $result->{data}, result => => 1 });
})->catch(sub($err) {
$self->render(json => { 'result' => 0, data => $err });
})->w
t()->then(sub ($result){
$self->render(json => { data => $result->{data}, result => => 1 });
})->catch(sub ($err) {
$self->render(json => { 'result' => 0, data => $err });
});
use strict;
use warnings;
use Test::More;
use JSON::PP;
use JQ::Lite;
my $json = <<'JSON';
{
"items": [
{ "name": "Widget", "value": 1 },
{ "value": 2, "active": true },
{ "nested": { "
],
"single": { "foo": "bar" },
"no_hashes": ["alpha", "beta"]
}
JSON
my $jq = JQ::Lite->new;
my @merged = $jq->run_query($json, '.items | merge_objects');
is_deeply(
\@merged,
[
e => JSON::PP::true,
nested => { id => 42 },
}
],
'merge_objects folds arrays of objects into one hash with later values winning',
);
my @single = $jq->run_query($json, '.
use strict;
use warnings;
use Test::More;
use JQ::Lite;
my $json = q({
"price": 19.2,
"discount": 1.5,
"debt": -1.7,
"tiny": -0.2,
"numbers": [1.49, 1.5, -1.49, -1.5, "n/a", null, [2.6, -2.
@round_price = $jq->run_query($json, '.price | round');
is($round_price[0], 19, 'round rounds positive scalar down when < .5');
my @round_discount = $jq->run_query($json, '.discount | round');
is($ro
nd_debt = $jq->run_query($json, '.debt | round');
is($round_debt[0], -2, 'round rounds negative scalar away from zero when beyond -.5');
my @round_tiny = $jq->run_query($json, '.tiny | round');
is($r
use strict;
use warnings;
use Test::More;
use JQ::Lite;
my $json = q({
"users": [
{
"name": "Alice",
"friends": [ { "name": "Charlie" }, { "name": "Dave" } ]
},
{
"nam
iends": [ { "name": "Eve" } ]
}
]
});
my $jq = JQ::Lite->new;
my @result = $jq->run_query($json, ".users[].friends[].name");
is_deeply(\@result, ['Charlie', 'Dave', 'Eve'], 'Multi-level array
::Lite->new;
sub run_query {
my ($json, $query) = @_;
return [ $jq->run_query($json, $query) ];
}
subtest 'pick on single object' => sub {
my $json = '{"name":"Alice","age":30,"city":
"Paris"}';
my $results = run_query($json, 'pick("name", "age")');
is_deeply(
$results->[0],
{ name => 'Alice', age => 30 },
'returns subset of keys'
);
};
subtest
ay of objects' => sub {
my $json = '{"users":[{"name":"Alice","age":30,"email":"alice@example.com"},{"name":"Bob","age":27}]}';
my $results = run_query($json, '.users | pick("name", "email"
->new;
my $simple_json = '{"a":1,"b":2}';
my @simple = $jq->run_query($simple_json, '.a, .b');
is_deeply(\@simple, [1, 2], 'comma emits multiple top-level values');
my $users_json = '[{"name":"Alice
query($users_json, '.[] | (.name, .age)');
is_deeply(\@flat, ['Alice', 30, 'Bob', 25], 'comma branches run against identical inputs in pipelines');
my @arrays = $jq->run_query($users_json, '.[] | [.n
],
'comma preserves evaluation order for each input');
my @prefixed = $jq->run_query($users_json, '(["name","age"]), (.[] | [.name, .age])');
is_deeply(
\@prefixed,
[
['name', 'a
gs;
use Test::More;
use JQ::Lite;
my $json = q({
"number": -10,
"numbers": [-3, 4, -5, "n/a"]
});
my $jq = JQ::Lite->new;
my @scalar = $jq->run_query($json, '.number | abs');
is($scalar[0], 10,
'abs converts scalar numbers to absolute value');
my @array = $jq->run_query($json, '.numbers | abs');
is_deeply(
$array[0],
[3, 4, 5, 'n/a'],
'abs converts numeric array entries and lea
-list
ls : list
[CMD]$(NOECHO) $(NOOP)
#
# Clean
#
clean purge ::
[CMD]- $(RM_F) \
[CMD]MYMETA.json \
[CMD]MYMETA.yml
[CMD]- $(RM_F) $(PROJECT).yml $(PROJECT).pid
[CMD]- $(RM_RF) \
[CMD]*.bak *.tmp
ngs;
use Test::More;
use JQ::Lite;
my $json = <<'JSON';
{
"users": ["Alice", "Bob", "Carol"]
}
JSON
my $jq = JQ::Lite->new;
is_deeply([$jq->run_query($json, '.users | nth(0)')], ['Alice'], 'nth(0
jq->run_query($json, '.users | nth(1)')], ['Bob'], 'nth(1) is Bob');
is_deeply([$jq->run_query($json, '.users | nth(2)')], ['Carol'], 'nth(2) is Carol');
is_deeply([$jq->run_query($json, '.users | nth
my $json = q({
"numbers": [1, 2, 3, 4],
"user": { "name": "Alice" }
});
my $jq = JQ::Lite->new;
my @drop_0 = $jq->run_query($json, '.numbers | drop(0)');
my @drop_2 = $jq->run_query($json, '.n
umbers | drop(2)');
my @drop_5 = $jq->run_query($json, '.numbers | drop(5)');
my @non_array = $jq->run_query($json, '.user | drop(1)');
is_deeply($drop_0[0], [1, 2, 3, 4], 'drop(0) keeps all elements
my $json_ordered = q([1, 2, 3, 4, 5]);
my ($p0) = $jq->run_query($json_ordered, 'percentile(0)');
my ($p25) = $jq->run_query($json_ordered, 'percentile(25)');
my ($p50) = $jq->run_query($json_order
ed, 'percentile');
my ($p100) = $jq->run_query($json_ordered, 'percentile(100)');
is($p0, 1, 'percentile(0) returns the minimum value');
is($p25, 2, 'percentile(25) returns the first quartile');
is($
) returns the maximum value');
my $json_interp = q([10, 20, 30, 40]);
my ($p90) = $jq->run_query($json_interp, 'percentile(0.90)');
my ($p75) = $jq->run_query($json_interp, 'percentile(75)');
is($p9
use warnings;
use autodie qw(:all);
use File::Glob ':glob';
use File::Slurp;
use File::stat;
use JSON::MaybeXS;
use POSIX qw(strftime);
use Readonly;
Readonly my %config => (
github_user => 'nigelh
r_db => 'cover_db/cover.json',
output => 'cover_html/index.html'
);
# Read and decode coverage data
my $json_text = read_file($config{cover_db});
my $data = decode_json($json_text);
my $coverage_pc
ob("coverage_history/*.json");
# Cache historical data instead of reading for each file
my %historical_cache;
for my $hist_file (@history_files) {
my $json = eval { decode_json(read_file($hist_file)
ey)->then(sub($result) {
$self->render(json => { data => $result->{data}, result => => 1 });
})->catch(sub($err) {
$self->render(json => { 'result' => 0, data => $err });
})->w
ey)->then(sub($result) {
$self->render(json => { data => $result->{data}, result => => 1 });
})->catch(sub($err) {
$self->render(json => { 'result' => 0, data => $err });
})->w
package NVMPL::Remote;
use strict;
use warnings;
use feature 'say';
use HTTP::Tiny;
use JSON::PP qw(decode_json);
use File::Spec;
use NVMPL::Config;
use NVMPL::Utils qw(log_info log_warn log_error);
my $cachefile = File::Spec->catfile($install_dir, 'node_index_cache.json');
my $ttl = $cfg->{cache_ttl};
my $json_data;
my $use_cache = 0;
if (-f $cachefile) {
my $age =
!";
local $/;
$json_data = <$fh>;
close $fh;
}
}
unless ($use_cache) {
my $url = "$mirror/index.json";
log_info("Fetching remote ve
ey)->then(sub($result) {
$self->render(json => { data => $result->{data}, result => => 1 });
})->catch(sub($err) {
$self->render(json => { 'result' => 0, data => $err });
})->w
ey)->then(sub($result) {
$self->render(json => { data => $result->{data}, result => => 1 });
})->catch(sub($err) {
$self->render(json => { 'result' => 0, data => $err });
})->w