Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/JSONPathLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class JSONPathLexer
public const MATCH_QUERY_MATCH = '\s* \?\(.+?\) \s*'; // Eg. ?(@.foo = "bar")
public const MATCH_INDEX_IN_SINGLE_QUOTES = '\s* \' (.+?)? \' \s*'; // Eg. 'bar'
public const MATCH_INDEX_IN_DOUBLE_QUOTES = '\s* " (.+?)? " \s*'; // Eg. "bar"
public const MATCH_MULTI_INDEX = '[\w+]+[^\,]|[\"\']+'; // Matches name,year or '''name''','''year'''

/**
* The expression being lexed.
Expand Down Expand Up @@ -231,6 +232,20 @@ protected function createToken(string $value): JSONPathToken
if ($ret !== null) {
return $ret;
}
// This idea could work for multi index matching
// Calling and on each of the objects i.e.
// if(preg_match('/^'. static::MATCH_MULTI_INDEX . '/$xu',$value,$matches)){
// $value = explode(",",trim($value,","))
// $len = count($value);
// $objs = array()
// for($value as $i=>$v){
// array_push($objs,new JSONPathToken(JSONPathToken::T_INDEX, $v));
// }
// Result of prev obj is the base for the query in the next object
// That is if the prev object returns all the person starting with A
// And the next is the age
// Then the One's named A is the search space for the age one's
// }

throw new JSONPathException("Unable to parse token {$tokenValue} in expression: $this->expression");
}
Expand Down