PatchBase: JSON iterator returns first hit

This commit is contained in:
Steffen Lange 2021-10-24 00:26:57 +02:00
parent 444ab7f26a
commit 405fe950b8

View file

@ -74,11 +74,13 @@ abstract class PatchBase {
return false;
}
protected function parse_json(string $key, string $re = '/(.*)/') : bool {
$flat = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data)));
if (!empty($flat[$key])) {
$this->data = $flat[$key];
$it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data));
foreach ($it as $k => $v) {
if ($key == $k) {
$this->data = $v;
return $this->parse($re);
}
}
return false;
}
protected function parse_yaml(string $key, string $re = '/(.*)/') : bool {