isJson() && ! empty($request->getContent())) { try { json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $exception) { throw new BadRequestHttpException(__('exceptions.api.malformed_json', ['error' => $exception->getMessage()]), $exception); } } return $next($request); } }