<p>Maybe I didn't fully understand you...
But, I think what you need is to make your own module and hook the event from FeedMe.</p>
<pre><code>    use craft\feedme\services\Process;
    use craft\feedme\events\FeedProcessEvent;
    use craft\feedme\events\FeedDataEvent;
    use craft\feedme\services\DataTypes;
    use craft\elements\Entry;

Event::on(DataTypes::class, DataTypes::EVENT_AFTER_PARSE_FEED, static function (FeedDataEvent $event): void {
   if (!$event-&gt;response['success']) {
      return;
   }

   $data = $event-&gt;response['data'];
   // .. Deal with data here, e.g. parse correctly JSON or change it
}
</code></pre>
<p>Or probably something like that</p>
<pre><code>Event::on(Process::class, Process::EVENT_STEP_AFTER_ELEMENT_SAVE, function (FeedProcessEvent $event) {
    $myEntry = $event-&gt;element;
    // ... Change your JSON structure or do what you want after element saved
}
</code></pre>

CC BY-SA 4.0
2022-07-07T07:19:25.350Z
Okay so the right thing to do would be to change the JSON data so that it will be workable for Feed Me. I'll look into it.
noregt
CC BY-SA 4.0
2022-07-07T10:06:17.470Z
I've had success with pasting JSON data into a string variable into Chrome's console, then using JavaScript to manipulate the data to turn it into a format that's easier to use with Feed Me. Lots of `.map()` to get the data into more consistent formats! Once it's right, you can copy it out from the console and paste into a JSON file to use with Feed Me.
Martin Spain
CC BY-SA 4.0
2022-07-06T20:40:34.380Z
2022-07-06T20:40:34.380Z
RomanAvr
<p>I'm working with a live stock API and want to import the products on a daily basis (using a cron job probably). At this moment I've setup a Feed Me feed as entries. This works for all products where the data is presented one by one. But the data does also have a part with an array and inside that array also columns, arrays like this:</p>
<pre><code>{
   &quot;supplier_data_columns&quot;: [&quot;value1&quot;, &quot;value2&quot;, &quot;value3&quot; {
    &quot;properties&quot;: {
      &quot;203&quot;: &quot;width_package&quot;,
      &quot;205&quot;: &quot;height_package&quot;,
      &quot;206&quot;: &quot;length_package&quot;
    }
  }]
}

</code></pre>
<p>This is then used in the article descriptions:</p>
<pre><code>&quot;supplier_data&quot;: [
      [&quot;F.15852&quot;, &quot;Scott&quot;, &quot;2557&quot; {
      &quot;203&quot;: &quot;50&quot;,
      &quot;205&quot;: &quot;40&quot;,
      &quot;206&quot;: &quot;100&quot;
      }]
</code></pre>
<p>How do I address this? Is this even possible with Feed Me? Do I need to import the whole array at once as &quot;supplier data&quot; and then extract the right columns in the entry? Or is a module needed here?</p>

<plugin-feedme><array><import>
Import a JSON file that uses arrays
# Import a JSON file that uses arrays

(Asked by: username_0 on 2022-07-06)

I'm working with a live stock API and want to import the products on a daily basis (using a cron job probably). At this moment I've setup a Feed Me feed as entries. This works for all products where the data is presented one by one. But the data does also have a part with an array and inside that array also columns, arrays like this:
{
   "supplier_data_columns": ["value1", "value2", "value3" {
    "properties": {
      "203": "width_package",
      "205": "height_package",
      "206": "length_package"
    }
  }]
}


This is then used in the article descriptions:
"supplier_data": [
      ["F.15852", "Scott", "2557" {
      "203": "50",
      "205": "40",
      "206": "100"
      }]

How do I address this? Is this even possible with Feed Me? Do I need to import the whole array at once as "supplier data" and then extract the right columns in the entry? Or is a module needed here?

**Tags:** plugin-feedme, array, import


---

## 1 answers

### Answer by username_1 on 2022-07-06. Score: 1

Maybe I didn't fully understand you...
But, I think what you need is to make your own module and hook the event from FeedMe.
    use craft\feedme\services\Process;
    use craft\feedme\events\FeedProcessEvent;
    use craft\feedme\events\FeedDataEvent;
    use craft\feedme\services\DataTypes;
    use craft\elements\Entry;

Event::on(DataTypes::class, DataTypes::EVENT_AFTER_PARSE_FEED, static function (FeedDataEvent $event): void {
   if (!$event->response['success']) {
      return;
   }

   $data = $event->response['data'];
   // .. Deal with data here, e.g. parse correctly JSON or change it
}

Or probably something like that
Event::on(Process::class, Process::EVENT_STEP_AFTER_ELEMENT_SAVE, function (FeedProcessEvent $event) {
    $myEntry = $event->element;
    // ... Change your JSON structure or do what you want after element saved
}

> **Comments:**
> **username_0**: Okay so the right thing to do would be to change the JSON data so that it will be workable for Feed Me. I'll look into it.  
> **username_2**: I've had success with pasting JSON data into a string variable into Chrome's console, then using JavaScript to manipulate the data to turn it into a format that's easier to use with Feed Me. Lots of `.map()` to get the data into more consistent formats! Once it's right, you can copy it out from the console and paste into a JSON file to use with Feed Me.  

---

