use JSON::XS ();
use POSIX qw(locale_h);
BEGIN {
our (@EXPORT, @EXPORT_OK);
@EXPORT = qw(
html_encode html_decode uri_escape check_email idn_to_unicode get_domain to_json from_json for
e {
return;
}
}
=head2 to_json
B<Arguments:>
=over
=item
B<$data> - scalar.
=back
B<Return value:> string, C<$data> as JSON.
=cut
sub to_json($;%) {
my ($data, %opts) = @_;
my $res;
if ($opts{'pretty'}) {
$res = JSON::XS->new->utf8->allow_nonref->pretty->encode($data);
} else {
$res = JSON::XS->new->utf8->allow_nonref->encode($data);
}