在编写用于请求 json 对象的函数时,在 Kotlin 中出现错误“Expecting body class”

Getting Error " Expecting body class" in Kotlin while writing function for requesting json objects

我正在编写一个函数,用于从 Youtube 数据中请求对象和字符串 API 这是代码

private fun gettingRequest(x:String)
{
    val url :String = "https://www.googleapis.com/youtube/v3/videos?id=" + x+
            "&key=API_KEY&part=snippet"

    val jsonObject = object : JsonObjectRequest( url,null ,Response.Listener {

        val success  = it.getBoolean("success")
        if(success){

            val items = it.getJSONObject("items")
            val uid = items.getString("id")
            val snippet = items.getJSONObject("snippet")
            val title_video = snippet.getString("title")
            val description = snippet.getString("description")
            val thumbnails = snippet.getJSONObject("thumbnails")
            val default = thumbnails.getJSONObject("default")
            val thumbnailDetails = thumbnail(default.getString("url"),
                default.getInt("width"),default.getInt("height"))
            details.add(data_math(uid,title_video,description,thumbnailDetails))
        }

    },
    Response.ErrorListener {

    })
    

} // error here

错误显示 Expecting a class body 请帮我解决这个问题

删除 object :。您似乎想要实例化一个 JsonObjectRequest 对象,而不是它的匿名子类(缺少主体)。