You are here

protected function JmesPathLinesParser::parseItems in Feeds extensible parsers 8

Performs the actual parsing.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed source.

\Drupal\feeds\Result\FetcherResultInterface $fetcher_result: The fetcher result.

\Drupal\feeds\Result\ParserResultInterface $result: The parser result object to populate.

\Drupal\feeds\StateInterface $state: The state object.

Overrides ParserBase::parseItems

File

src/Feeds/Parser/JmesPathLinesParser.php, line 61

Class

JmesPathLinesParser
Defines a JSON Lines parser using JMESPath.

Namespace

Drupal\feeds_ex\Feeds\Parser

Code

protected function parseItems(FeedInterface $feed, FetcherResultInterface $fetcher_result, ParserResultInterface $result, StateInterface $state) {
  $expressions = $this
    ->prepareExpressions();
  $variable_map = $this
    ->prepareVariables($expressions);
  foreach ($this->iterator as $row) {
    $row = $this
      ->getEncoder()
      ->convertEncoding($row);
    try {
      $row = $this->utility
        ->decodeJsonArray($row);
    } catch (RuntimeException $e) {

      // An array wasn't returned. Skip this item.
      continue;
    }
    if ($item = $this
      ->executeSources($row, $expressions, $variable_map)) {
      $result
        ->addItem($item);
    }
  }
}