Aion-Format
view release on metacpan or search on metacpan
t/aion/format/json.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//; use Test::More 0.98; use String::Diff q...
# # NAME
#
# Aion::Format::Json - ÑаÑÑиÑение Perl Ð´Ð»Ñ ÑоÑмаÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ JSON
#
# # SYNOPSIS
#
subtest 'SYNOPSIS' => sub {
use Aion::Format::Json;
local ($::_g0 = do {to_json {a => 10}}, $::_e0 = "{\n \"a\": 10\n}\n"); ::ok $::_g0 eq $::_e0, 'to_json {a => 10} # => {\n "a": 10\n}\n' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {from_json '[1, "5"]'}, $::_e0 = do {[1, "5"]}); ::is_deeply $::_g0, $::_e0, 'from_json \'[1, "5"]\' # --> [1, "5"]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# # DESCRIPTION
#
# `Aion::Format::Json` иÑполÑзÑÐµÑ Ð² каÑеÑÑве оÑÐ½Ð¾Ð²Ñ `JSON::XS`. РвклÑÑÐ°ÐµÑ ÑледÑÑÑие наÑÑÑойки:
#
# * allow_nonref â ÑкалÑÑÑ ÐºÐ¾Ð´Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ð¸ декодиÑованиÑ.
# * indent â вклÑÑиÑÑ Ð¼Ð½Ð¾Ð³Ð¾ÑÑÑоÑнÑй ÑекÑÑ Ñ Ð¾ÑÑÑÑпом в наÑале ÑÑÑоки.
# * space_after â `\n` поÑле json.
# * canonical â ÑоÑÑиÑовка клÑÑей в Ñ
еÑаÑ
.
#
# # SUBROUTINES
#
# ## to_json (;$data)
#
# ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð´Ð°Ð½Ð½Ñе в ÑоÑÐ¼Ð°Ñ json.
#
::done_testing; }; subtest 'to_json (;$data)' => sub {
my $data = {
a => 10,
};
my $result = '{
"a": 10
}
';
local ($::_g0 = do {to_json $data}, $::_e0 = do {$result}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'to_json $data # -> $result' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local $_ = $data;
local ($::_g0 = do {to_json}, $::_e0 = do {$result}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'to_json # -> $result' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## from_json (;$string)
#
# РазбиÑÐ°ÐµÑ ÑÑÑÐ¾ÐºÑ Ð² ÑоÑмаÑе JSON в ÑÑÑÑкÑÑÑÑ Perl.
#
::done_testing; }; subtest 'from_json (;$string)' => sub {
local ($::_g0 = do {from_json '{"a": 10}'}, $::_e0 = do {{a => 10}}); ::is_deeply $::_g0, $::_e0, 'from_json \'{"a": 10}\' # --> {a => 10}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {[map from_json, "{}", "2"]}, $::_e0 = do {[{}, 2]}); ::is_deeply $::_g0, $::_e0, '[map from_json, "{}", "2"] # --> [{}, 2]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# # AUTHOR
#
# Yaroslav O. Kosmina <darviarush@mail.ru>
#
# # LICENSE
#
( run in 2.332 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )