diff --git a/composer.json b/composer.json index 05d2eb8c..4d53f52f 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ }, "require": { "php": "^7.1", + "ext-json": "*", "monolog/monolog": "^1.23", "symfony/config": "^4.0", "symfony/filesystem": "^4.0", diff --git a/src/Manifest/ManifestManager.php b/src/Manifest/ManifestManager.php index 0d067fc1..23a52495 100644 --- a/src/Manifest/ManifestManager.php +++ b/src/Manifest/ManifestManager.php @@ -5,13 +5,12 @@ namespace Keboola\Component\Manifest; use InvalidArgumentException; +use Keboola\Component\JsonFileHelper; use Keboola\Component\Manifest\ManifestManager\Options\OutFileManifestOptions; use Keboola\Component\Manifest\ManifestManager\Options\OutTableManifestOptions; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Serializer\Encoder\JsonEncoder; -use const PATHINFO_EXTENSION; -use function file_get_contents; use function pathinfo; +use const PATHINFO_EXTENSION; /** * Handles everything related to generating and reading manifests for tables and files. @@ -98,8 +97,7 @@ private function loadManifest(string $fileName, string $baseDir): array return []; } - $decoder = new JsonEncoder(); - return $decoder->decode(file_get_contents($manifestFilename), JsonEncoder::FORMAT); + return JsonFileHelper::read($manifestFilename); } /** @@ -108,10 +106,7 @@ private function loadManifest(string $fileName, string $baseDir): array */ private function internalWriteManifest(string $manifestAbsolutePath, array $manifestContents): void { - $encoder = new JsonEncoder(); - $manifestJson = $encoder->encode($manifestContents, JsonEncoder::FORMAT); - $filesystem = new Filesystem(); - $filesystem->dumpFile($manifestAbsolutePath, $manifestJson . "\n"); + JsonFileHelper::write($manifestAbsolutePath, $manifestContents, false); } /**