se case, however, the output was needed in
JSON format, not HTML. One solution would have been to use the text-based
templating system to produce a valid JSON document (quite risky). The other solutio
in code, and use a JSON serializer on that, bypassing the template
output.
The third solution would have been to provide a template that did not directly
produce the serialised JSON text, but describ
orking only with structured data, and never with text,
the serialized output must always be valid JSON.
This (minus the serialization) is the domain of C<Positron::DataTemplate>.
=head1 EXAMPLES
Th
es via filename.
If C<$filename> ends in C<.json> or C<.js>, the file is assumed to be in JSON
format, and will be parsed with a freshly C<require>d C<JSON> module.
Otherwise, it is assumed to be an
lename (Storable / JSON / eval?)
if ($filename =~ m{ \. (json|js) $ }xms) {
require JSON; # should use JSON::XS if available
require File::Slurp;
my $json = File::Slurp::re
ad_file($filename);
return JSON->new->utf8->allow_nonref->decode($json);
} else {
# Storable
require Storable;
my $dom = Storable::retrieve($filename);
retu