private function remove(&$json, array $pointerParts)
{
$pointerPart = array_shift($pointerParts);
if (is_array($json) && isset($json[$pointerPart])) {
if (count($pointerParts) === 0) {
unset($json[$pointerPart]);
if (ctype_digit($pointerPart)) {
$json = array_values($json);
}
} else {
$this->remove($json[$pointerPart], $pointerParts);
}
} elseif (is_object($json) && isset($json->{$pointerPart})) {
if (count($pointerParts) === 0) {
unset($json->{$pointerPart});
} else {
$this->remove($json->{$pointerPart}, $pointerParts);
}
} elseif ($pointerPart === Pointer::LAST_ARRAY_ELEMENT_CHAR && is_array($json)) {
unset($json[count($json) - 1]);
} else {
if (null === $pointerPart) {
$json = new \stdClass();
} elseif (is_object($json)) {
unset($json->{$pointerPart});
} else {
unset($json[$pointerPart]);
}
}
}