Closed stevevance closed 7 years ago
I think the correct approach would be casting the array to json in a transformation step.
Maybe I have time to make that transformer at night, but you can make your own custom transformation by implementing the Marquine\Etl\Transformers\ TransformerInterface
interface and do:
$job->extract('json', 'path/to/file.json')
->transform(Your\Custom\Transformation::class, $options)
->load('table', 'table_name');
I agree that's the correct approach, but I don't understand, currently, where to write that class or how Your\Custom\Transformation namespaces work.
@stevevance, sorry for the late reply.
I just tagged a new version with the JsonEncode Transformer. Now you can do:
$job->transform('JsonEncode', ['columns' => ['columnName']]);
@leomarquine Thank you, I'll try it out soon.
I am extracting data where there is more than one level of objects with properties. In PHP this would be a multi-dimension array.
Sample data:
When I extract the
sponsorships
array, I want to preserve it as an array and load it into a JSON type field in a PostgreSQL database.To do that, I added this code to
/src/Loaders/Table.php
before line 168 in functioninsert()
. I don't think it will work on a 3-dimension array (array[array[array[]]]), but it works on my 2-dimension array.