Json.set所在位置是kotlin.js.Json.set,其相關用法介紹如下。

用法:

abstract operator fun set(propertyName: String, value: Any?)

該函數的調用將被轉換為 value 分配給使用 propertyName 索引(使用方括號/索引操作)的接收器。

例如:對於以下代碼:

fun test(j: Json, p: String, newValue: Any) {
    j["prop"] = 1
    j.set(p, newValue)
}

將生成:

function test(j, p, newValue) {
    j["prop"] = 1;
    j[p] = newValue;
}
}