Aion-Format

 view release on metacpan or  search on metacpan

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


1;

__END__

=encoding utf-8

=head1 NAME

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

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

=back

=head1 SUBROUTINES

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

=head2 from_json (;$string)

Parses a JSON string into a Perl structure.

	from_json '{"a": 10}' # --> {a => 10}
	
	[map from_json, "{}", "2"]  # --> [{}, 2]

=head1 AUTHOR

Yaroslav O. Kosmina L<mailto:darviarush@mail.ru>

=head1 LICENSE

âš– B<GPLv3>

=head1 COPYRIGHT

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



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