Aion-Format

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

            "Test::CPAN::Meta" : "0",
            "Test::MinimumVersion::Fast" : "0.04",
            "Test::PAUSE::Permissions" : "0.07",
            "Test::Pod" : "1.41",
            "Test::Spellunker" : "v0.2.7"
         }
      },
      "runtime" : {
         "requires" : {
            "Data::Printer" : "0",
            "JSON::XS" : "4.03",
            "List::Util" : "0",
            "POSIX" : "0",
            "Term::ANSIColor" : "0",
            "common::sense" : "0",
            "config" : "1.3",
            "perl" : "v5.22.0"
         }
      },
      "test" : {
         "requires" : {

META.yml  view on Meta::CPAN

    file: lib/Aion/Format.pm
    version: v0.0.10
  Aion::Format::Html:
    file: lib/Aion/Format/Html.pm
  Aion::Format::Json:
    file: lib/Aion/Format/Json.pm
  Aion::Format::Url:
    file: lib/Aion/Format/Url.pm
requires:
  Data::Printer: '0'
  JSON::XS: '4.03'
  List::Util: '0'
  POSIX: '0'
  Term::ANSIColor: '0'
  common::sense: '0'
  config: '1.3'
  perl: v5.22.0
resources:
  bugtracker: https://github.com/darviarush/perl-aion-format/issues
  homepage: https://github.com/darviarush/perl-aion-format
  repository: https://github.com/darviarush/perl-aion-format.git

cpanfile  view on Meta::CPAN

    requires 'Data::Printer', '1.000004';
    requires 'Liveman', '1.0';
};

on 'test' => sub {
	requires 'Test::More', '0.98';
};

requires 'common::sense';
requires 'config', '1.3';
requires 'JSON::XS', '4.03';
requires 'List::Util';
requires 'POSIX';
requires 'Term::ANSIColor';
requires 'Data::Printer';

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` based on `JSON::XS`. And includethe following settings:

* allow_nonref - coding and decoding scalars.
* indent - enable multiline with indent on begin lines.
* space_after - `\n` after json.
* canonical - sorting keys in hashes.

# 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> based on C<JSON::XS>. And includethe following settings:

=over

=item * allow_nonref - coding and decoding scalars.

=item * indent - enable multiline with indent on begin lines.

=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;

::is scalar do {to_json {a => 10}}, "{\n   \"a\": 10\n}\n", 'to_json {a => 10}    # => {\n   "a": 10\n}\n';
::is_deeply scalar do {from_json '[1, "5"]'}, scalar do {[1, "5"]}, 'from_json \'[1, "5"]\' # --> [1, "5"]';

# 
# # DESCRIPTION
# 
# `Aion::Format::Json` based on `JSON::XS`. And includethe following settings:
# 
# * allow_nonref - coding and decoding scalars.
# * indent - enable multiline with indent on begin lines.
# * space_after - `\n` after json.
# * canonical - sorting keys in hashes.
# 
# # SUBROUTINES
# 
# ## to_json (;$data)
# 



( run in 0.548 second using v1.01-cache-2.11-cpan-4d50c553e7e )