Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/Peekmo/JsonPath/JsonPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ private function trace($expr, $val, $path)
$this->trace($this->evalx($loc, $val, substr($path, strrpos($path, ";") + 1)) . ";" . $x, $val, $path);
}
else if (preg_match("/^\?\(.*?\)$/", $loc)) { // [?(expr)]
if ($this->evalx(preg_replace("/^\?\((.*?)\)$/", "$1", $loc), $val)) {
$this->trace($x, $val, $path);
}
$this->walk($loc, $x, $val, $path, array(&$this, "_callback_05"));
}
else if (preg_match("/^(-?[0-9]*):(-?[0-9]*):?(-?[0-9]*)$/", $loc)) { // [start:end:step] phyton slice syntax
Expand Down
17 changes: 7 additions & 10 deletions src/Peekmo/JsonPath/JsonStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,13 @@ public function get($expr, $unique = false)

if (true === $unique) {
if (!empty($values) && is_array($values[0])) {
array_walk($values, function(&$value) {
$value = json_encode($value);
});

$values = array_unique($values);
array_walk($values, function(&$value) {
$value = json_decode($value, true);
});

return array_values($values);
$tmpValues = array_map(function($value) {
return json_encode($value);
}, $values);

$tmpValues = array_unique($tmpValues);

return array_values(array_intersect_key($values, $tmpValues));
}

return array_unique($values);
Expand Down