Aion-Format

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

      },
      "runtime" : {
         "recommends" : {
            "Devel::Size" : "0"
         },
         "requires" : {
            "DDP" : "0",
            "Encode" : "0",
            "Exporter" : "0",
            "Guard" : "0",
            "JSON::XS" : "0",
            "List::Util" : "0",
            "POSIX" : "0",
            "Term::ANSIColor" : "0",
            "YAML::Syck" : "0",
            "bigint" : "0",
            "bytes" : "0",
            "common::sense" : "0",
            "config" : "0",
            "constant" : "0",
            "perl" : "v5.22.0"

META.yml  view on Meta::CPAN

    file: lib/Aion/Format/Url.pm
  Aion::Format::Yaml:
    file: lib/Aion/Format/Yaml.pm
recommends:
  Devel::Size: '0'
requires:
  DDP: '0'
  Encode: '0'
  Exporter: '0'
  Guard: '0'
  JSON::XS: '0'
  List::Util: '0'
  POSIX: '0'
  Term::ANSIColor: '0'
  YAML::Syck: '0'
  bigint: '0'
  bytes: '0'
  common::sense: '0'
  config: '0'
  constant: '0'
  perl: v5.22.0

cpanfile  view on Meta::CPAN

	requires 'open';
};

# Для DDP
recommends 'Devel::Size';

requires 'DDP';
requires 'Guard';
requires 'Encode';
requires 'Exporter';
requires 'JSON::XS';
requires 'List::Util';
requires 'POSIX';
requires 'Term::ANSIColor';
requires 'YAML::Syck';
requires 'bigint';
requires 'bytes';
requires 'common::sense';
requires 'config';
requires 'constant';

i18n/Aion/Format/Json.ru-en.po  view on Meta::CPAN

msgid "Aion::Format::Json - расширение Perl для форматирования JSON"
msgstr "Aion::Format::Json - Perl extension for JSON formatting"

msgid "`Aion::Format::Json` использует в качестве основы `JSON::XS`. И включает следующие настройки:"
msgstr "`Aion::Format::Json` uses `JSON::XS` as a base. And includes the following settings:"

msgid ""
"* allow_nonref — скаляры кодирования и декодирования.\n"
"* indent – включить многострочный текст с отступом в начале строки.\n"
"* space_after — `\\n` после json.\n"
"* canonical — сортировка ключей в хешах."
msgstr ""
"* allow_nonref - encoding and decoding scalars.\n"
"* indent – enable multiline text with indentation at the beginning of the line.\n"
"* space_after — `\\n` after json.\n"

lib/Aion/Format/Json.md  view on Meta::CPAN


```perl
use Aion::Format::Json;

to_json {a => 10}    # => {\n   "a": 10\n}\n
from_json '[1, "5"]' # --> [1, "5"]
```

# DESCRIPTION

`Aion::Format::Json` использует в качестве основы `JSON::XS`. И включает следующие настройки:

* allow_nonref — скаляры кодирования и декодирования.
* indent – включить многострочный текст с отступом в начале строки.
* space_after — `\n` после json.
* canonical — сортировка ключей в хешах.

# SUBROUTINES

## to_json (;$data)

lib/Aion/Format/Json.pm  view on Meta::CPAN

package Aion::Format::Json;

use common::sense;
use JSON::XS qw//;

use Exporter qw/import/;
our @EXPORT = our @EXPORT_OK = grep {
    *{$Aion::Format::Json::{$_}}{CODE} && !/^(_|(NaN|import)\z)/n
} keys %Aion::Format::Json::;

#@category json

# Настраиваем json
our $JSON = JSON::XS->new->allow_nonref->indent(1)->space_after(1)->canonical(1);

# Ð’ json
sub to_json(;$) {
	$JSON->encode(@_ == 0? $_: @_)
}

# Из json
sub from_json(;$) {
	$JSON->decode(@_ == 0? $_: @_)
}

lib/Aion/Format/Json.pm  view on Meta::CPAN


=head1 SYNOPSIS

	use Aion::Format::Json;
	
	to_json {a => 10}    # => {\n   "a": 10\n}\n
	from_json '[1, "5"]' # --> [1, "5"]

=head1 DESCRIPTION

C<Aion::Format::Json> uses C<JSON::XS> as a base. And includes the following settings:

=over

=item * allow_nonref - encoding and decoding scalars.

=item * indent – enable multiline text with indentation at the beginning of the line.

=item * space_after — C<\n> after json.

=item * canonical - sorting keys in hashes.

t/aion/format/json.t  view on Meta::CPAN

# 
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)
# 



( run in 1.458 second using v1.01-cache-2.11-cpan-39bf76dae61 )