NAME

Aion::Format::Json - Perl extension for JSON formatting

SYNOPSIS

use Aion::Format::Json;

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

DESCRIPTION

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

  • allow_nonref - encoding and decoding scalars.

  • indent – enable multiline text with indentation at the beginning of the line.

  • space_after — \n after json.

  • canonical - sorting keys in hashes.

SUBROUTINES

to_json (;$data)

Converts data to json format.

my $data = {
    a => 10,
};

my $result = '{
   "a": 10
}
';

to_json $data # -> $result

local $_ = $data;
to_json # -> $result

from_json (;$string)

Parses a JSON string into a Perl structure.

from_json '{"a": 10}' # --> {a => 10}

[map from_json, "{}", "2"]  # --> [{}, 2]

AUTHOR

Yaroslav O. Kosmina mailto:darviarush@mail.ru

LICENSE

GPLv3

COPYRIGHT

The Aion::Format::Json module is copyright © 2023 Yaroslav O. Kosmina. Rusland. All rights reserved.