The trick is to create a new parser, not a new fetcher.
I created a new module and a new parser at the following:
New files at MY_MODULE/src/Feeds/Parser/MymoduleJsonPathParser.php
I wanted to build on top of the feeds_ex module so I used their interfaces as the following:
use RuntimeException;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\feeds\FeedInterface;
use Drupal\feeds\Result\FetcherResultInterface;
use Drupal\feeds\Result\ParserResultInterface;
use Drupal\feeds\StateInterface;
use Peekmo\JsonPath\JsonStore;
use Drupal\feeds_ex\feeds\Parser\JsonParserBase;
use Drupal\feeds_ex\feeds\Parser\ParserBase;
use Drupal\Core\Form\FormStateInterface;
If you would like to add custom options that appear at the feeds UI add your custom form at the following:
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['FIELD'] = [ .....];
return $form;
}
Now you can build on your custom parser:
protected function executeContext(FeedInterface $feed, FetcherResultInterface $fetcher_result, StateInterface $state) {
$raw = $this->prepareRaw($fetcher_result);
$parsed = $this->utility->decodeJsonArray($raw);
// Your code gose here.
}
I am writing a custom module and I will share it here when it's finished.