You are here

protected function JsonPathLinesParser::executeSourceExpression in Feeds extensible parsers 8

Executes a single source expression.

Parameters

string $machine_name: The source machine name being executed.

string $expression: The expression to execute.

mixed $row: The row to execute on.

Return value

scalar|[]scalar Either a scalar, or a list of scalars. If null, the value will be ignored.

Overrides JsonPathParser::executeSourceExpression

File

src/Feeds/Parser/JsonPathLinesParser.php, line 90

Class

JsonPathLinesParser
Defines a JSON Lines parser using JSONPath.

Namespace

Drupal\feeds_ex\Feeds\Parser

Code

protected function executeSourceExpression($machine_name, $expression, $row) {
  $result = $this
    ->search($row, $expression);
  if (is_scalar($result)) {
    return $result;
  }

  // Return a single value if there's only one value.
  return count($result) === 1 ? reset($result) : $result;
}