You are here

protected function FeedsExJsonPathLines::parseItems in Feeds extensible parsers 7

Performs the actual parsing.

Parameters

FeedsSource $source: The feed source.

FeedsFetcherResult $fetcher_result: The fetcher result.

FeedsParserResult $result: The parser result object to populate.

Overrides FeedsExBase::parseItems

File

src/FeedsExJsonPathLines.inc, line 49
Contains FeedsExJsonPathLines.

Class

FeedsExJsonPathLines
Parses the JSON Lines format via JSONPath.

Code

protected function parseItems(FeedsSource $source, FeedsFetcherResult $fetcher_result, FeedsParserResult $result) {
  $expressions = $this
    ->prepareExpressions();
  $variable_map = $this
    ->prepareVariables($expressions);
  foreach ($this->iterator as $row) {
    $row = $this
      ->getEncoder()
      ->convertEncoding($row);
    try {
      $row = FeedsExJsonUtility::decodeJsonArray($row);
    } catch (RuntimeException $e) {

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