@@ -34,35 +34,32 @@ composer require flow-php/etl-adapter-json:~--FLOW_PHP_VERSION--
3434``` php
3535<?php
3636
37- use Flow\ETL\Adapter\JSON\JSONMachine\JsonExtractor;
37+ use function Flow\ETL\Adapter\JSON\from_json;
38+ use function Flow\ETL\DSL\{data_frame, to_output};
3839
39- $rows = (new Flow())
40- ->read(from_json(__DIR__ . '/../Fixtures/timezones.json', 5))
41- ->fetch()
40+ data_frame()
41+ ->read(from_json(__DIR__ . '/data.json'))
42+ ->collect()
43+ ->write(to_output())
44+ ->run();
4245```
4346
4447## Loader - JsonLoader
4548
4649``` php
4750<?php
4851
49- use function Flow\ETL\Adapter\JSON\{to_json};
50- use Flow\ETL\Flow;
51- use Flow\ETL\Row;
52- use Flow\ETL\Rows;
53-
54- (new Flow())
55- ->process(
56- new Rows(
57- ...\array_map(
58- fn (int $i) : Row => Row::create(
59- new Row\Entry\IntegerEntry('id', $i),
60- new Row\Entry\StringEntry('name', 'name_' . $i)
61- ),
62- \range(0, 10)
63- )
52+ use function Flow\ETL\Adapter\JSON\to_json;
53+ use function Flow\ETL\DSL\{data_frame, from_array};
54+
55+ data_frame()
56+ ->read(from_array(
57+ \array_map(
58+ fn (int $i) : array => ['id' => $i, 'name' => 'name_' . $i],
59+ \range(0, 10)
6460 )
65- )
61+ ))
62+ ->collect()
6663 ->write(to_json(\sys_get_temp_dir() . '/file.json'))
6764 ->run();
6865```
@@ -75,23 +72,17 @@ It is also possible to export the rows using the [json lines](https://jsonlines.
7572``` php
7673<?php
7774
78- use function Flow\ETL\Adapter\JSON\{to_json};
79- use Flow\ETL\Flow;
80- use Flow\ETL\Row;
81- use Flow\ETL\Rows;
82-
83- (new Flow())
84- ->process(
85- new Rows(
86- ...\array_map(
87- fn (int $i) : Row => Row::create(
88- new Row\Entry\IntegerEntry('id', $i),
89- new Row\Entry\StringEntry('name', 'name_' . $i)
90- ),
91- \range(0, 10)
92- )
75+ use function Flow\ETL\Adapter\JSON\to_json_lines;
76+ use function Flow\ETL\DSL\{data_frame, from_array};
77+
78+ data_frame()
79+ ->read(from_array(
80+ \array_map(
81+ fn (int $i) : array => ['id' => $i, 'name' => 'name_' . $i],
82+ \range(0, 10)
9383 )
94- )
95- ->write(to_json(\sys_get_temp_dir() . '/file.jsonl')->asJsonl())
84+ ))
85+ ->collect()
86+ ->write(to_json_lines(\sys_get_temp_dir() . '/file.jsonl'))
9687 ->run();
9788```
0 commit comments