diff --git a/src/ApiKernel.php b/src/ApiKernel.php index 723963f..37b38da 100644 --- a/src/ApiKernel.php +++ b/src/ApiKernel.php @@ -256,6 +256,21 @@ class ApiKernel return $node; } + private function encodeJson($value): string + { + $options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES; + $json = json_encode($value, $options, 2048); + if ($json === false) { + $json = json_encode( + $value, + $options | JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_INVALID_UTF8_SUBSTITUTE, + 2048 + ); + } + + return $json === false ? '' : $json; + } + // ================================================================= // 🚀 CRUD HANDLER METHODEN @@ -430,7 +445,7 @@ class ApiKernel $components = is_string($json) ? json_decode($json, true) : $json; if (is_array($components)) { $components = $this->cleanReferenceComponents($components); // BEREINIGUNG - $data[$jsonDbCol] = json_encode($components, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + $data[$jsonDbCol] = $this->encodeJson($components); } else { $data[$jsonDbCol] = is_string($json) ? $json : ''; }