ting, however the code of this development version may be broken!
package Math::Formula::Config::JSON;{
our $VERSION = '0.18';
}
use parent 'Math::Formula::Config';
use warnings;
use strict;
use L
calar::Util qw/blessed/;
use File::Slurper qw/read_binary/;
use Cpanel::JSON::XS ();
my $json = Cpanel::JSON::XS->new->pretty->utf8->canonical(1);
#--------------------
#-----------------
for($args{filename} || "$name.json");
open my $fh, '>:raw', $fn
or fault __x"Trying to save context '{name}' to {file}", name => $name, file => $fn;
$fh->print($json->encode($tree));
$fh->close
=encoding utf8
=head1 NAME
Math::Formula::Config::JSON - load/save formulas to file
=head1 INHERITANCE
Math::Formula::Config::JSON
is a Math::Formula::Config
=head1 SYNOPSIS
my $context =
fig::JSON->new(directory => $dir);
$config->save($context);
my $context = $config->load('test');
=head1 DESCRIPTION
Save and load a L<Math::Formula::Context|Math::Formula::Context> to JSON file
s.
You need to B<have installed Cpanel::JSON::XS>. That module is not in the
dependencies of this packages, because we do not want to add complications
to the main code.
Extends L<"DESCRIPTION" in
CE
Math::Formula::Config is extended by
Math::Formula::Config::INI
Math::Formula::Config::JSON
Math::Formula::Config::YAML
=head1 SYNOPSIS
my $saver = Math::Formula::Config::YAML->new(d
e following serialization formats are supported:
=over 4
=item * JSON via L<Math::Formula::Config::JSON|Math::Formula::Config::JSON>
=item * YAML via L<Math::Formula::Config::YAML|Math::Formula::Co
a back-up script, configured in JSON
"daily_backups" : "/var/tmp/backups/daily",
"weekly_backups" : "/var/tmp/backups/weekly",
# With Math::Formula::Config::JSON
"backup_dir" : "/var/tmp