DreamT has asked for the wisdom of the Perl Monks concerning the following question:
$external_structure = { 'name' => 'Test product', 'id' => 'ABC123', 'data' => { 'enabled' => '1', 'internal_id' => '', 'urls' => { 'main_url' => '' }, 'price' => '1000', 'unit' => 'ST', 'unit_info' => { 'qty' => '1', 'gtin' => '1234567890' } } };
However, let's say that an end user wants to control the mappings, without having knowledge about or access to the source code. In theory, the mappings could be put in a textfile/CRM system or similar, likemy $internal_structure = {}; $internal_structure->{'product_id'} = $external_structure->{'id'}; $internal_structure->{'price_excl_vat'} = $external_structure->{'data' +}->{'price'}; $internal_structure->{'qty'} = $external_structure->{'data'}->{'unit_i +nfo'}->{'qty'}; # etc...
(There are of course better ways to do it, but just to explain the principle)product_id;id price_excl_vat;data#price qty;data#unit_info#qty
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mapping data structures through external source
by choroba (Cardinal) on Aug 02, 2019 at 14:14 UTC | |
by Aldebaran (Curate) on Aug 02, 2019 at 19:33 UTC | |
by DreamT (Pilgrim) on Aug 05, 2019 at 07:43 UTC | |
by haukex (Archbishop) on Aug 05, 2019 at 09:07 UTC | |
|
Re: Mapping data structures through external source
by Fletch (Bishop) on Aug 02, 2019 at 20:01 UTC |