I expect it should work:
```
:) select CAST(CAST('{"x" : 1}', 'Object(\'json\')'), 'Object(Nullable(\'json\'))')

SELECT CAST(CAST('{"x" : 1}', 'Object(\'json\')'), 'Object(Nullable(\'json\'))')

Query id: fb057b45-b72a-4d22-9b38-a3136cdf2465


0 rows in set. Elapsed: 0.002 sec.

Received exception from server (version 22.5.1):
Code: 53. DB::Exception: Received from localhost:9000. DB::Exception: Cast to Object can be performed only from flatten named Tuple, Map or String. Got: Object('json'): While processing CAST(CAST('{"x" : 1}', 'Object(\'json\')'), 'Object(Nullable(\'json\'))'). (TYPE_MISMATCH)
```

@CurtizJ what do you think?
};
        bool cast_ipv4_ipv6_default_on_conversion_error_value = cast_ipv4_ipv6_default_on_conversion_error;
        auto make_custom_serialization_wrapper = [&, cast_ipv4_ipv6_default_on_conversion_error_value](const auto & types) -> bool
        {
            using Types = std::decay_t<decltype(types)>;
            using ToDataType = typename Types::RightType;
            using FromDataType = typename Types::LeftType;
            if constexpr (WhichDataType(FromDataType::type_id).isStringOrFixedString())
            {
                if (to_type->getCustomSerialization() && to_type->getCustomName())
                {
                    if (to_type->getCustomName()->getName() == "IPv4")
                    {
                        ret = [cast_ipv4_ipv6_default_on_conversion_error_value](
                                  ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, const ColumnNullable *, size_t)
                            -> ColumnPtr
                        {
                            if (!WhichDataType(result_type).isUInt32())
                                throw Exception(ErrorCodes::TYPE_MISMATCH, "Wrong result type {}. Expected UInt32", result_type->getName());
                            if (cast_ipv4_ipv6_default_on_conversion_error_value)
                                return convertToIPv4<IPStringToNumExceptionMode::Default>(arguments[0].column);
                            else
                                return convertToIPv4<IPStringToNumExceptionMode::Throw>(arguments[0].column);
                        };
                        return true;
                    }
                    if (to_type->getCustomName()->getName() == "IPv6")
                    {
                        ret = [cast_ipv4_ipv6_default_on_conversion_error_value](
                                  ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, const ColumnNullable *, size_t)