encode_json#

Perl data to UTF-8 encoded JSON text.

Synopsis#

use JSON::PP;
my $bytes = encode_json { name => "caf\x{e9}" };   # {"name":"caf\xc3\xa9"}

What you get back#

The JSON text as UTF-8 bytes: JSON::PP->new->utf8->encode($data). Exported by default.