Open gonzus opened 4 years ago
Use JSON::PP::encode_json
. Module JSON::PP
is a prereq for JSON5
,
so you do not need to install it, you do not need to add a use JSON::PP
into you program. Example:
use JSON5;
my %chem_elem = (H => 1, He => 2, Li => 3);
print JSON::PP::encode_json(\%chem_elem), "\n";
As mentioned in JSON5.org, JSON5 is aimed at human-written files, such as config files. In another website (sorry, I do not remember which website), I have read that JSON v4 is still relevant for machine-written files and that any program dumping data as JSON should use the stricter v4 version.
See also this comparison.
Module JSON5 deals with human-to-machine communication, not
machine-to-machine or machine-to-human communication. So the module
does not support encode
. It is lighter, shorter and it follows the
KISS principle (keep it simple, stupid) and Occam's Razor (Entities
must not be multiplied beyond necessity).
J Forget
Is there any reason why there is no support for
encode
?