mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-26 05:27:26 +02:00
Use JSON::PP instead of JSON since it is shipped with core Perl.
This commit is contained in:
parent
ab4efce5d1
commit
5ada7fb5ad
@ -54,7 +54,7 @@ apt-get install postgresql-server-dev-9.3
|
|||||||
```
|
```
|
||||||
* Install required Perl modules:
|
* Install required Perl modules:
|
||||||
```
|
```
|
||||||
cpanm JSON
|
cpanm JSON::PP
|
||||||
cpanm Net::OpenSSH
|
cpanm Net::OpenSSH
|
||||||
cpanm IPC::System::Simple
|
cpanm IPC::System::Simple
|
||||||
cpanm Digest::SHA
|
cpanm Digest::SHA
|
||||||
@ -731,7 +731,7 @@ example: db-path=/data/db
|
|||||||
|
|
||||||
### v0.75: IN DEVELOPMENT: enterprise features: monitoring, throttling, retention period
|
### v0.75: IN DEVELOPMENT: enterprise features: monitoring, throttling, retention period
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
### v0.65: Improved resume and restore logging, compact restores
|
### v0.65: Improved resume and restore logging, compact restores
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
</code-block>
|
</code-block>
|
||||||
* Install required Perl modules:
|
* Install required Perl modules:
|
||||||
<code-block>
|
<code-block>
|
||||||
cpanm JSON
|
cpanm JSON::PP
|
||||||
cpanm Net::OpenSSH
|
cpanm Net::OpenSSH
|
||||||
cpanm IPC::System::Simple
|
cpanm IPC::System::Simple
|
||||||
cpanm Digest::SHA
|
cpanm Digest::SHA
|
||||||
|
@ -14,7 +14,7 @@ use Time::HiRes qw(gettimeofday usleep);
|
|||||||
use POSIX qw(ceil);
|
use POSIX qw(ceil);
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use Cwd qw(abs_path);
|
use Cwd qw(abs_path);
|
||||||
use JSON;
|
use JSON::PP;
|
||||||
|
|
||||||
use lib dirname($0) . '/../lib';
|
use lib dirname($0) . '/../lib';
|
||||||
use BackRest::Exception;
|
use BackRest::Exception;
|
||||||
@ -545,6 +545,10 @@ sub ini_load
|
|||||||
open($hFile, '<', $strFile)
|
open($hFile, '<', $strFile)
|
||||||
or confess &log(ERROR, "unable to open ${strFile}");
|
or confess &log(ERROR, "unable to open ${strFile}");
|
||||||
|
|
||||||
|
# Create the JSON object
|
||||||
|
my $oJSON = JSON::PP->new();
|
||||||
|
|
||||||
|
# Read the INI file
|
||||||
while (my $strLine = readline($hFile))
|
while (my $strLine = readline($hFile))
|
||||||
{
|
{
|
||||||
$strLine = trim($strLine);
|
$strLine = trim($strLine);
|
||||||
@ -572,7 +576,7 @@ sub ini_load
|
|||||||
# Try to store value as JSON
|
# Try to store value as JSON
|
||||||
eval
|
eval
|
||||||
{
|
{
|
||||||
${$oConfig}{"${strSection}"}{"${strKey}"} = decode_json($strValue);
|
${$oConfig}{"${strSection}"}{"${strKey}"} = $oJSON->decode($strValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
# On error store value as a scalar
|
# On error store value as a scalar
|
||||||
@ -606,6 +610,10 @@ sub ini_save
|
|||||||
open($hFile, '>', $strFile)
|
open($hFile, '>', $strFile)
|
||||||
or confess &log(ERROR, "unable to open ${strFile}");
|
or confess &log(ERROR, "unable to open ${strFile}");
|
||||||
|
|
||||||
|
# Create the JSON object canonical so that fields are alpha ordered and pass unit tests
|
||||||
|
my $oJSON = JSON::PP->new()->canonical();
|
||||||
|
|
||||||
|
# Write the INI file
|
||||||
foreach my $strSection (sort(keys $oConfig))
|
foreach my $strSection (sort(keys $oConfig))
|
||||||
{
|
{
|
||||||
if (!$bFirst)
|
if (!$bFirst)
|
||||||
@ -625,7 +633,7 @@ sub ini_save
|
|||||||
{
|
{
|
||||||
if (ref($strValue) eq "HASH")
|
if (ref($strValue) eq "HASH")
|
||||||
{
|
{
|
||||||
syswrite($hFile, "${strKey}=" . to_json($strValue, {canonical => true}) . "\n")
|
syswrite($hFile, "${strKey}=" . $oJSON->encode($strValue) . "\n")
|
||||||
or confess "unable to write key ${strKey}: $!";
|
or confess "unable to write key ${strKey}: $!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user