Flow\JSONPath\JSONPath::find PHP Method

find() public method

Evaluate an expression
public find ( $expression ) : static
$expression
return static
    public function find($expression)
    {
        $tokens = $this->parseTokens($expression);
        $collectionData = [$this->data];
        foreach ($tokens as $token) {
            $filter = $token->buildFilter($this->options);
            $filteredData = [];
            foreach ($collectionData as $value) {
                if (AccessHelper::isCollectionType($value)) {
                    $filteredValue = $filter->filter($value);
                    $filteredData = array_merge($filteredData, $filteredValue);
                }
            }
            $collectionData = $filteredData;
        }
        return new static($collectionData, $this->options);
    }

Usage Example

Esempio n. 1
0
 /**
  * Automatically generated method, will be overridden
  *
  * @param Request $request      	
  * @return Response
  */
 public function run(Request $request)
 {
     $json = Json::decode($request->getContent());
     $path = new JSONPath($json);
     $login = $path->find('$.data.attributes.login')->first();
     $password = $path->find('$.data.attributes.password')->first();
     $domain = new SessionDomain($this->getServiceContainer());
     $payload = $domain->login($login, $password);
     return $this->responder->run($request, $payload);
 }
All Usage Examples Of Flow\JSONPath\JSONPath::find