File Coverage

blib/lib/Aion/Format/Json.pm
Criterion Covered Total %
statement 11 11 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 22 22 100.0


line stmt bran cond sub pod time code
1             package Aion::Format::Json;
2              
3 1     1   131083 use common::sense;
  1         1  
  1         5  
4 1     1   732 use JSON::XS qw//;
  1         6258  
  1         33  
5              
6 1     1   5 use Exporter qw/import/;
  1         1  
  1         262  
7             our @EXPORT = our @EXPORT_OK = grep {
8             *{$Aion::Format::Json::{$_}}{CODE} && !/^(_|(NaN|import)\z)/n
9             } keys %Aion::Format::Json::;
10              
11             #@category json
12              
13             # Настраиваем json
14             our $JSON = JSON::XS->new->allow_nonref->indent(1)->space_after(1)->canonical(1);
15              
16             # В json
17             sub to_json(;$) {
18 3 100   3 1 138174 $JSON->encode(@_ == 0? $_: @_)
19             }
20              
21             # Из json
22             sub from_json(;$) {
23 4 100   4 1 3919 $JSON->decode(@_ == 0? $_: @_)
24             }
25              
26             1;
27              
28             __END__