protected function FeedsExJmesPathLines::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/
FeedsExJmesPathLines.inc, line 51 - Contains FeedsExJmesPathLines.
Class
- FeedsExJmesPathLines
- Parses JSON Lines documents with JMESPath.
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;
}
}
}