isJson() && !empty($request->getContent())) { try { json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage()); } } return $next($request); } }