diff --git a/src/adapter/etl-adapter-json/src/Flow/ETL/Adapter/JSON/RowsNormalizer/EntryNormalizer.php b/src/adapter/etl-adapter-json/src/Flow/ETL/Adapter/JSON/RowsNormalizer/EntryNormalizer.php index 65cbf9f97..2a887fecc 100644 --- a/src/adapter/etl-adapter-json/src/Flow/ETL/Adapter/JSON/RowsNormalizer/EntryNormalizer.php +++ b/src/adapter/etl-adapter-json/src/Flow/ETL/Adapter/JSON/RowsNormalizer/EntryNormalizer.php @@ -26,10 +26,10 @@ public function normalize(Entry $entry) : string|float|int|bool|array|null Entry\DateEntry::class => $entry->value()?->format($this->dateFormat), Entry\TimeEntry::class => $entry->value() ? date_interval_to_microseconds($entry->value()) : null, Entry\EnumEntry::class => $entry->value()?->name, + Entry\JsonEntry::class => $entry->value(), Entry\ListEntry::class, Entry\MapEntry::class, Entry\StructureEntry::class, - Entry\JsonEntry::class, Entry\XMLElementEntry::class => $entry->toString(), Entry\XMLEntry::class => $entry->toString(), default => $entry->value(), diff --git a/src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JsonTest.php b/src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JsonTest.php index ec40ad3f9..542722ca4 100644 --- a/src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JsonTest.php +++ b/src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JsonTest.php @@ -6,7 +6,7 @@ use function Flow\ETL\Adapter\JSON\from_json; use function Flow\ETL\Adapter\Json\to_json; -use function Flow\ETL\DSL\{average, df, from_array, overwrite, ref}; +use function Flow\ETL\DSL\{average, df, from_array, from_rows, int_entry, json_entry, overwrite, ref, row}; use function Flow\ETL\DSL\{config, flow_context, rows}; use function Flow\Filesystem\DSL\path; @@ -113,6 +113,28 @@ public function test_json_loader_overwrite_mode() : void } } + public function test_jsonentry_json_file() : void + { + $jsonObject = ['short' => 'short_description', 'long' => 'long_description']; + df() + ->read(from_rows(rows( + row( + int_entry('id', 1), + json_entry('nested', $jsonObject), + ) + ))) + ->saveMode(overwrite()) + ->write(to_json($path = __DIR__ . '/var/test_jsonentry.json')) + ->run(); + + self::assertStringContainsString( + <<<'JSON' +[{"id":1,"nested":{"short":"short_description","long":"long_description"}}] +JSON, + \file_get_contents($path) + ); + } + public function test_partitioning_json_file() : void { df()